Implement 3 scheduling algorithms, FIFO, SJF, SRT based on following actions: The simulation maintains the current time,...

90.2K

Verified Solution

Question

Programming

Implement 3 scheduling algorithms, FIFO, SJF, SRT based onfollowing actions:

The simulation maintains the current time, t, which isinitialized to 0 and is incremented after each simulation step.Each simulation step then consists of the following actions:

repeat until Ráµ¢ == 0 for all n processes /* repeat until allprocesses have terminated */
while no process is active, increment t /* if no process is readyto run, just advance t */
choose active processes páµ¢ to run next
according to scheduling algorithm /* Ex: FIFO, SJF, SRT */
decrement Ráµ¢ /* páµ¢ has accumulated 1 CPU time unit */
if Ráµ¢ == 0 /* process i has terminated */
set active flag of páµ¢ = 0 /* process i is excluded from furtherconsideration */
TTáµ¢ = t - Aáµ¢ /* the turnaround time of process i is the time
since arrival, TTáµ¢, until the current time t */
compute the average turnaround time,
ATT, by averaging all values TTáµ¢

Answer & Explanation Solved by verified expert
4.5 Ratings (654 Votes)
FIFOFirst Come First Served FCFS also known as First In FirstOutFIFO is the CPU scheduling algorithm in which the CPU isallocated to the processes in the order they are queued in theready queueFCFS follows nonpreemptive scheduling which mean once the CPUis allocated to a process it does not leave the CPU until theprocess will not get terminated or may get halted due to some IOinterruptExampleLets say there are four processes arriving in the sequence asP2 P3 P1 with their corresponding execution time as shown in thetable below Also taking their arrival time to be 0ProcessOrder of arrivalExecution time in msecP1315P213P323Gantt chart showing the waiting time of processes P1 P2 and P3in the systemAs shown aboveThe waiting time of process P2 is 0The waiting time of process P3 is 3The waiting time of process P1 is 6Average time 0 3 6 3 3 msecAs we have taken arrival time to be 0 therefore turn around timeand completion time will be sameExampleInput processes P1 P2 P3 Burst time 5 8 12OutputProcesses Burst Waiting Turn around1 5 0 52 8 5 133 12 13 25Average Waiting time 6000000Average turn around time 14333333AlgorithmStart Step 1 In function int waitingtimeint proc int n int bursttime int waittime Set waittime0 0 Loop For i 1 and i n and i Set waittimei bursttimei1 waittimei1 End ForStep 2 In    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students