Functions | |
void | sched_enter_critical_region () |
Disable the scheduling of the other tasks.
| |
void | sched_leave_critical_region () |
Re-enable scheduling for the other tasks. | |
bool | is_sched_enabled () |
Return if the scheduling is enabled or not. | |
__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). |
|
Return if the scheduling is enabled or not.
Definition at line 1070 of file task.c.
01071 { 01072 if( atomic_read(&sched_enabled) ) 01073 return( TRUE ); 01074 else 01075 return( FALSE ); 01076 } |
|
Disable the scheduling of the other tasks.
Definition at line 1055 of file task.c.
01056 { 01057 DOWN( &sched_enabled ); 01058 } |
|
Re-enable scheduling for the other tasks.
Definition at line 1061 of file task.c.
01062 { 01063 UP( &sched_enabled ); 01064 } |
|
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 } |
|
A semaphore to enable or disable scheduling (used to manage critical regions).
|