Functions | |
| void | dispatcher () |
| The dispatcher. | |
|
|
The dispatcher.
This routine supplies to change the context of the tasks. It is invoked at every clock tick. Definition at line 1131 of file task.c.
01132 {
01133 task_t *prev_task;
01134
01135 // Call the clock task at every tick //
01136 clock_thread();
01137
01138 // Can we switch to another process?! //
01139 if ( atomic_read(&sched_enabled) )
01140 {
01141 // Store the previous task //
01142 prev_task = curr_task;
01143 // Select a new task //
01144 scheduler();
01145
01146 if ( prev_task != curr_task )
01147 {
01148 if ( prev_task->tss.cr3 != curr_task->tss.cr3 )
01149 {
01150 // Update the page directory of the //
01151 // new task with the kernel page //
01152 // directory in the kernel memory area. //
01153 __asm__ __volatile__ (
01154 "movl %%eax, %%cr3\n"
01155 "cld\n"
01156 "rep movsl\n"
01157 "movl %%ebx, %%cr3" : :
01158 "a"(curr_task->tss.cr3),
01159 "b"(prev_task->tss.cr3),
01160 "D"((dword *)PAGE_DIR_MAP+(K_VIR_START/(PAGE_SIZE*1024))),
01161 "S"((dword *)K_PDBR+(K_VIR_START/(PAGE_SIZE*1024))),
01162 "c"((PAGE_DIR_MAP/(PAGE_SIZE*1024)) - (K_VIR_START/(PAGE_SIZE*1024)))
01163 );
01164 __asm__("" : : : "%eax", "%ebx", "%ecx", "%edi", "%esi");
01165 }
01166
01167 // Re-enable master interrupt controller //
01168 outportb(PORT_8259_M, EOI);
01169 // Perform the task switch //
01170 jmp_to_tss(curr_task->tss_sel);
01171 }
01172 }
01173 }
|
1.2.18