schedtest.c

来自「geekos 0.3.0简单的操作系统」· C语言 代码 · 共 51 行

C
51
字号
#include <conio.h>#include <process.h>#include <sched.h>#include <sema.h>#include <string.h>#if !defined (NULL)#define NULL 0#endifint main(int argc , char ** argv){  int policy = -1;  int quantum;  int id1, id2, id3;    	/* ID of child process */  if (argc == 3) {    if (!strcmp(argv[1], "rr")) {      policy = 0;    } else if (!strcmp(argv[1], "mlf")) {      policy = 1;    } else {      Print("usage: %s [rr|mlf] <quantum>\n", argv[0]);      Exit(1);    }    quantum = atoi(argv[2]);    Set_Scheduling_Policy(policy, quantum);  } else {    Print("usage: %s [rr|mlf] <quantum>\n", argv[0]);    Exit(1);  }  quantum = atoi(argv[2]);  Set_Scheduling_Policy(policy, quantum);  id3 = Spawn_Program ( "/c/sched3.exe", "/c/sched3.exe") ;  id1 = Spawn_Program ( "/c/sched1.exe", "/c/sched1.exe") ;  id2 = Spawn_Program ( "/c/sched2.exe", "/c/sched2.exe") ;    Wait(id1);  Wait(id2);  Wait(id3);  Print("\n");  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?