Write a C or C++ program that performs runs of the following process scheduling algorithms: *Shortest remaining time (SRT) [preemptive] *Round robin (RR) [preemptive] Run each scheduling algorithm for 100 quanta (time slices), labeled 0 through 99. Before each run of an algorithm, create 20 simulated processes. Each simulated process is simply a small data structure that stores information about the process that it represents. For each simulated process, randomly generate: • An arrival time: a float value from quanta 0 through 99. • An expected total run time: a float value from 0.1 through 10 quanta. • A priority: integer 1, 2, 3, or 4 (1 is highest) • Include any other attributes that you may need Tip: While debugging your program, you may want the same pseudo-random numbers each time. For this to happen, you should set the seed of the random number generator to a value, such as 0. Read about the rand() and srand() functions for C and C++: Assume only one CPU and one ready queue. Sort the simulated processes in the ready queue by arrival time. Your process scheduler can do process switching only at the start of each time quantum. For this assignment, only consider CPU time for each process (no I/O wait times, no process switching overhead). For RR, use a time slice of 1 quantum. Each simulation run should last until the completion of the last process, even if it goes beyond 100 quanta. No process should get the CPU for the first time after time quantum 99. Run each algorithm 5 times to get averages for the statistics below. Before each run, clear the process queue and create a new set of simulated processes.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a C or C++ program that performs runs of the following process scheduling algorithms:

*Shortest remaining time (SRT) [preemptive]

*Round robin (RR) [preemptive]

Run each scheduling algorithm for 100 quanta (time slices), labeled 0 through 99. Before each run of an algorithm, create 20 simulated processes. Each simulated process is simply a small data structure that stores information about the process that it represents.

For each simulated process, randomly generate: • An arrival time: a float value from quanta 0 through 99. • An expected total run time: a float value from 0.1 through 10 quanta. • A priority: integer 1, 2, 3, or 4 (1 is highest) • Include any other attributes that you may need

Tip: While debugging your program, you may want the same pseudo-random numbers each time. For this to happen, you should set the seed of the random number generator to a value, such as 0. Read about the rand() and srand() functions for C and C++:

Assume only one CPU and one ready queue. Sort the simulated processes in the ready queue by arrival time. Your process scheduler can do process switching only at the start of each time quantum. For this assignment, only consider CPU time for each process (no I/O wait times, no process switching overhead). For RR, use a time slice of 1 quantum.

Each simulation run should last until the completion of the last process, even if it goes beyond 100 quanta. No process should get the CPU for the first time after time quantum 99.

Run each algorithm 5 times to get averages for the statistics below. Before each run, clear the process queue and create a new set of simulated processes.

Your output should include:

• The sorted contents of the ready queue before the start of the run.

-Each created process’s name (such as A, B, C, ...), arrival time, expected run time, and priority.

• A timeline of the 100+ quanta that shows which process ran during each quantum, such as ABCDABCD ...

- Show a process’s name in a quantum even if it completed execution before the end of that quantum.

- The CPU can be idle during the last part of a quantum if a process completes before the end of the quantum. (No need to show the idle time within a quantum.) - Show a hyphen - if a quantum is completely unused.

• Calculated statistics for each algorithm run:

- Average turnaround time for the processes that ran. o

-Average waiting time for the processes that ran.

-How many processes in the ready queue that never ran.

- Throughput of the algorithm per 100 quanta: number of completed processes X 100 / quanta total quanta to complete the process

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY