?? test.2.cpp
字號:
// Test Preemptive Shortest Job First scheduling #include "system.h"#include "list.h"#include "testcase.h"//----------------------------------------------------------------------// ThreadTest2// Preemptive SJF scheduling algorithm// Process Burst Time Priority Arrival// P1 10 0 120// P2 29 0 0// P3 3 0 200// P4 7 0 180// P5 12 0 100//----------------------------------------------------------------------void ThreadTest2(){ int numThreads = 5; int startTime[] = {120, 0,200,180,100 }; int burstTime[] = { 10, 29, 3, 7, 12 }; int priority[] = { 0, 0, 0, 0, 0 }; 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_SRTN); printf("Starting at "); stats->PrintElapsedTicks(); printf("Queuing threads.\n"); TestScheduler( ( int ) procList );}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -