Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Linked List, Write a C language program to implement a CPU priority scheduler. Description We are given with the n number of processes i.e.

Using Linked List, Write a C language program to implement a CPU priority scheduler.

Description

We are given with the n number of processes i.e. P1, P2, P3,......., Pn with their corresponding burst times and priorities associated with each process. The task is to find the average waiting time, average turnaround time, and the sequence of process execution using the priority CPU scheduling algorithm.

In the priority scheduling algorithm, each process has a priority associated with it and as each process hits the queue, it is stored in based on its priority so that processes with higher priority are dealt with first. In this case, the priority follows: 0>1>2>3>4, which means that 0 has a higher priority than 1, 2, 3 and 4.

Your program must read a list of tasks from the following table and schedule them based priority scheduling algorithm. Each line in the task file describes a single task. Each process has a name(ex. P1,P2 etc), a priority, and a CPU burst time. Priority is represented by an integer number; CPU burst is also represented by an integer number, which indicates the CPU time required to finish the task.

Process Priority Burst Time
P1 2 6
P2 4 12
P3 0 3
P4 1 10

You must implement a linked list to hold the tasks in the memory after reading from the table and to facilitate the scheduling from an in-memory list. You must write a scheduler program that will take the name of the task file as an argument, read the tasks from the table, add each task to the scheduler list. (linked list), and finally, schedule the tasks using priority scheduling programs. Also, it will display the waiting time as well as the turnaround time as well. Your code will also calculate the average waiting time and the average turnaround time.

Your code will have the following sample output:

image text in transcribed

What is Waiting Time and Turnaround Time? Turnaround Time is the time interval between the submission of a process and its completion. Turnaround Time = completion of a process submission of a process Waiting Time is the difference between turnaround time and burst time Waiting Time = turnaround time burst time

Process P[3] P[4] P[1] P[2] Burst Time 3 10 6 12 Waiting Time 0 3 13 19 Turnaround Time 3 13 19 31 Average Waiting Time=8 Average Turnaround Time=16

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Big Data, Mining, And Analytics Components Of Strategic Decision Making

Authors: Stephan Kudyba

1st Edition

1466568704, 9781466568709

More Books

Students also viewed these Databases questions