global.c
修改了task_table,将任务替换为读者写者问题的内容。修改了系统调用表,加入了新增的系统调用
kernel.asm
这里借用了7o的框架代码中已有的系统调用,不过框架的是有三个参数,我改成了只有一个参数
main.c
修改了任务表初始化和各种全局变量初始化部分,以及增加了各个任务的定义。
PUBLIC TASK task_table[NR_TASKS] = {
//{task_tty, STACK_SIZE_TTY, "tty"}
{A, STACK_SIZE_A, "A"},
{B, STACK_SIZE_B, "B"},
{C, STACK_SIZE_C, "C"},
{D, STACK_SIZE_D, "D"},
{E, STACK_SIZE_E, "E"},
{F, STACK_SIZE_F, "F"},};
PUBLIC system_call sys_call_table[NR_SYS_CALL] = {sys_get_ticks, sys_write,
sys_sleep, sys_p, sys_v};
sys_call:
call save
; push dword [p_proc_ready]
sti
push ecx
; push ebx
call [sys_call_table + eax * 4]
; add esp, 4 * 3
add esp, 4
mov [esi + EAXREG - P_STACKBASE], eax
cli
ret
PUBLIC int kernel_main()
{
...
proc_table[0].needTimeSlice = proc_table[0].priority = 2;
proc_table[1].needTimeSlice = proc_table[1].priority = 3;
proc_table[2].needTimeSlice = proc_table[2].priority = 3;
proc_table[3].needTimeSlice = proc_table[3].priority = 3;
proc_table[4].needTimeSlice = proc_table[4].priority = 4;
proc_table[5].needTimeSlice = proc_table[5].priority = 1;
proc_table[0].type = proc_table[1].type = proc_table[2].type = 'r';
proc_table[3].type = proc_table[4].type = 'w';
proc_table[5].type = 'n';
proc_table[0].done = proc_table[1].done = proc_table[2].done =
proc_table[3].done = proc_table[4].done = proc_table[5].done = 0;