Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Please answer the following question: Create a program for Priority Scheduling in C language. The program is expected to take 5 processes with the following

Please answer the following question:

Create a program for Priority Scheduling in C language. The program is expected to take 5 processes with the following attributes: a) Process ID (int) b) Burst Time (int) c) Priority (int)

In order to use Process as a collection of attributes, you should use struct in C language.

Once you have created a Process struct, create 5 processes in the main method. You are free to hardcode these values using an array of Processes, e.g., {{1, 10, 3}, {2, 1, 1}, {3, 2, 4}, {4, 1,5}, {5, 5, 2}} where {1, 10, 3} is the first process and {2, 1, 1} is second and so on. 1 in the first process is the Process ID, 10 is the Burst Time and 3 is the Priority as illustrated above as the attributes of the Process.

After populating the Processes, show the Process ID, Burst Time and Priority of all the processes as shown below in the expected output screenshot.

Since, you are programming Priority Scheduling, you are required to sort processes in the ascending order of their priority. You are free to use any method to sort the processes in the array, however, C has a good qsort function that can help in doing that.

Once sorted, calculate the wait time and turnaround time for all the processes and display on the console as shown in the expected output screenshot. Do not forget to calculate the average wait time for priority scheduling. Please refer to the expected output screenshot for the program.

PLEASE REFER TO THE SCREENSHOT BELOW AS THAT IS SUPPOSED TO BE THE EXPECTED OUTPUT.

INPUT: ./file1.o

OUTPUT:

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions