Você está na página 1de 2

Jim Heffernan Assignment 4 Problem of the Week # 2 Algorithm (pseudocode): (Round Robin (RR) Scheduling)

03/02/98 10:24:10 AM

let (time) quantum be 2 (sec.) ---time slice if countQueue(CPUQUEUE) equals 1 THEN --- is a process (tran) running ? if headqueue[CPUQUEUE] PCB_run equals 0 THEN --- process has completed take process off CPU if countQueue(READYQUEUE) greater than 0 THEN issue_process onto CPU decrement time quantum counter else --- process has not completed if headqueue[CPUQUEUE] time quantum equals 0 THEN --- time's up! if countQueue(READYQUEUE) greater than 0 THEN remove process from CPUQ and insert into READYQUEUE reset time quantum counter issue next available process onto CPUQ decrement time quantum counter else ----no processes (trans) in ready queue reset time quantum counter run for a tick decrement time quantum counter else ---quantum has not expi red run for a tick decrement time quantum counter else ---CPU is idle if (countQueue(READYQUEUE) greater than 0 THEN issue process onto CPU decrement time quantum counter end_if end_if end_if end_if end_if end Assumptions: -----------------1. Round Robin (RR) Scheduling Algorithm. 2. Time Slice (or time quantum) is set at 2 seconds for each user process before the next user process get control of the CPU. 3. Preemption (when process switches state) is added between processes. If a user process exceeds the time-slice it is preempted and put back on the Ready Queue. 4. Time-slice setting may affect performance: If time-slice too large - degenerates to FCFS (first-come-first-serve) and can result in the convoy effect where one process keeps the CPU until it releases; less context switching. If time-slice too small - more context switching for/to new processes.

The givens: 1. Its a FIFO Round Robin (RR) Scheduling Algorithm with a 2 second time quantum for each user process before the next user process get control of the CPU. Its preemptive - if a user process exceeds the time-slice it is preempted and put back on the Ready Queue.

2.

The Algorithm again (in my English): I come in with the list processes and loop through the scheduler function: I check to see is a process is already running (if the CPUQ = 1)? If not, I assume the CPU is idle and issue a process on the CPUQ and decrement the time quantum counter. Next, I check to see if a process has completed? If so, I take the process off the CPUQ and issue a new process and decrement the time quantum counter. Else If the process has NOT completed, I check to see if its time is up? If it is and the READYQ is greater than zero, I (1) remove the process from the CPUQ and insert itback on the READYQ, (2) reset the time quantum counter, (3) issue the next available process onto the CPUQ and (4) decrement the time quantum counter. Else If the process has NOT completed and there are no processes on the READYQ, I (1) reset the time quantum, (2) run for a tick and (3) decrement the time quantum counter. Else Finally, if the time quantum has NOT expired, I (1) run for a tick and (2) decrement the time quantum counter. I return back and execute until there are no more processes.

Você também pode gostar