CS452 - Real-Time Programming - Fall 2009

Lecture 8 - Create( ), Scheduling

Reminder


Creating a Task

In creating a task you have to do two things

  1. Get and initialize resources needed by the task
  2. Make the task look as if it had just entered the kernel

Things you need to do

Get an unused TD and memory for its stack

Mostly filling in fields in the TD.

  1. task id
  2. stack pointer
  3. SPSR
  4. link register
  5. parent tid
  6. return value
  7. state
  8. install in the ready queues

Must also create the initial stack


The Create Function

You also need a int Create( int priority, void (*code) ( ) ) function to call from user tasks.

Although it's no more than a wrapper there are a few problems to solve.

  1. Passing arguments
  2. Jumping into the kernel
  3. Getting the return value from the kernel and returning it.

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

How to implement the queues

one sorted queue

fast activation


Return to: