test.1.cc

来自「基于nachos模拟器的源代码」· CC 代码 · 共 46 行

CC
46
字号
//     Test Nonpreemptive Priority scheduling //#include "system.h"#include "list.h"#include "testcase.h"//----------------------------------------------------------------------// ThreadTest2//      Priority scheduling algorithm//      Order of arrival: All at same time 0//      Process  Burst Time  Priority//        P1        10          7//        P2        29          5//        P3         3          9//        P4         7          8//        P5        12          6//----------------------------------------------------------------------void ThreadTest1(){     int  numThreads = 5;    int  startTime[] = {  0,  0,  0,  0,  0  };    int  burstTime[] = { 10, 29,  3,  7, 12  };    int   priority[] = {  7,  5,  9,  8,  6, };    schedpair * a_pair;    List<schedpair *> * procList = new List<schedpair *>();    for( int i = 0; i < numThreads; i++ ) {       a_pair = new schedpair;       a_pair->burst = burstTime[i];       a_pair->prior = priority[i];       procList->SortedInsert( a_pair, startTime[i] );    }    scheduler->SetSchedPolicy(SCHED_PRIO_NP);    printf("Starting at ");    stats->PrintElapsedTicks();    printf("Queuing threads.\n");    TestScheduler( ( int ) procList );}

⌨️ 快捷键说明

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