Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

The Scheduler
[Multitasking]


Functions

void sched_enter_critical_region ()
 Disable the scheduling of the other tasks.
Warning:
ATTENTION!!! Remember to call sched_leave_critical_region() when the task exits from the critical region. Otherwise the whole system could be blocked, because the scheduling of the other tasks is disabled after a task calls this function.


void sched_leave_critical_region ()
 Re-enable scheduling for the other tasks.

bool is_sched_enabled ()
 Return if the scheduling is enabled or not.
Returns:
  • TRUE if the scheduling is enabled
  • FALSE otherwise.


__inline__ void scheduler ()
 This is a simple round robin scheduler.


Variables

semaphore_t sched_enabled
 A semaphore to enable or disable scheduling (used to manage critical regions).


Detailed Description

The routines for the tasks scheduling.

Function Documentation

bool is_sched_enabled  
 

Return if the scheduling is enabled or not.

Returns:
  • TRUE if the scheduling is enabled
  • FALSE otherwise.

Definition at line 1070 of file task.c.

01071 {
01072         if( atomic_read(&sched_enabled) )
01073                 return( TRUE );
01074         else
01075                 return( FALSE );
01076 }

void sched_enter_critical_region  
 

Disable the scheduling of the other tasks.

Warning:
ATTENTION!!! Remember to call sched_leave_critical_region() when the task exits from the critical region. Otherwise the whole system could be blocked, because the scheduling of the other tasks is disabled after a task calls this function.

Definition at line 1055 of file task.c.

01056 {
01057         DOWN( &sched_enabled );
01058 }

void sched_leave_critical_region  
 

Re-enable scheduling for the other tasks.

Definition at line 1061 of file task.c.

01062 {
01063         UP( &sched_enabled );
01064 }

__inline__ void scheduler   [static]
 

This is a simple round robin scheduler.

This routine is called by the dispatcher() every time a task must be scheduled.

Definition at line 1083 of file task.c.

01084 {
01085         task_t *p=NULL;
01086         int count;
01087 
01088         // Look for the tasks that need to sleep.
01089         count = count_queue( &ready_queue );
01090         for ( ; count; --count )
01091         {
01092                 p = pick_queue( &ready_queue );
01093                 if ( p->state==WAIT )
01094                 {
01095                         rem_queue( &ready_queue, p );
01096                         add_queue( &wait_queue,  p );
01097                 }
01098         }
01099 
01100         // Look for the tasks that need to wake-up.
01101         count = count_queue( &wait_queue );
01102         for ( ; count; --count )
01103         {
01104                 p = pick_queue( &wait_queue );
01105                 if ( p->state==READY )
01106                 {
01107                         rem_queue( &wait_queue,  p );
01108                         add_queue( &ready_queue, p );
01109                 }
01110         }
01111 
01112         // Select a new task to run (Round Robin).
01113         curr_task = pick_queue( &ready_queue );
01114         if (curr_task == NULL) curr_task=idle_task;
01115 }


Variable Documentation

semaphore_t sched_enabled
 

A semaphore to enable or disable scheduling (used to manage critical regions).

Definition at line 1047 of file task.c.


Generated on Fri Feb 20 15:32:23 2004 for Minirighi by doxygen1.2.18