CS452 - Real-Time Programming - Spring 2009

Lecture 9 - Tasks, Scheduling

Practical Detail


Tasks

Kernel maintains a task descriptor (TD) for each created task. That is, to create a task the kernel must allocate a TD and initialize it. The TD normally contains

  1. The task id
  2. The task's stack pointer, which points to a private stack containing

    all ready to be reloaded whenever the task next runs.

  3. The return value for when the task is next activated
  4. The task's parent
  5. The task's state
  6. Priority Queue information

Possible states of the task

  1. Active: running or about to run
  2. Ready: can run if scheduled
  3. Blocked: waiting for something to happen
  4. Defunct: will never run again

Diagram


Creating a Task

Get an unused TD and memory for its stack

Mostly filling in fields in the TD.

  1. task id
  2. stack pointer
  3. parent id
  4. return value
  5. state

Must also create the initial stack

Must link into the correct priority queue.


Scheduling

When to schedule

Whenever we leave the kernel. When do we enter the kernel?

  1. Tasks run to completion
  2. Event-driven pre-emption
  3. Time-slicing

Who to Schedule

  1. active task decides = co-processes
  2. round robin
  3. priorities
    1. fixed at compile time
    2. fixed when task is created
    3. re-fixed every time task is scheduled
      • Do you have a good algorithm
  4. hybrid
  5. determined by type of kernel entry

What God has Decided

Hybrid

What you decide

  1. How many priorities
  2. Which task should have which priority
  3. How to implement the queues

Return to: