Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Multi - Level Feedback Implement the Multi - Level Feedback Queue ( MLFQ ) scheduling algorithm and calculate the average waiting time and turnaround time

Multi-Level Feedback
Implement the Multi-Level Feedback Queue (MLFQ) scheduling algorithm and calculate the average waiting time and turnaround time for a set of processes by:
Defining Process and Queue Structures:
Create a Process structure to store necessary information for each process, such as process ID, duration, remaining time, waiting time, and turnaround time.
Create a Queue structure to represent a queue in the MLFQ, which holds processes, has a front and rear indicator, and a time quantum associated with it.
Initializing Queues:
Implement a function to initialize your queues with appropriate time quanta. For example, a high-priority queue might have a smaller time quantum, and a low-priority queue might have a larger time quantum.
Gathering Input:
Prompt the user to enter the number of processes.
For each process, ask the user to input the process ID and its duration.
Initialize the remaining time for each process and enqueue them to the high-priority queue.
MLFQ Implementation:
Implement the MLFQ scheduling algorithm. Processes start in the high-priority queue and move to lower-priority queues if they do not finish within their time quantum.
Ensure that you update the waiting time, turnaround time, and remaining time for each process as they are scheduled and executed.
Print informative messages to show the state of the system, such as when a process is running, when it is moved to a different queue, and when it finishes execution.
Calculating Averages and Displaying Results:
After all processes have finished execution, calculate the average waiting time and average turnaround time.
Display the waiting time, turnaround time, and other relevant information for each process.
Present the calculated averages to the user.
Testing Your Implementation:
Test your implementation with various sets of processes and time quanta to ensure that it behaves as expected.
You can use the provided example to verify the correctness of your implementation.
Example Input:
3
10
20
30
Example Output:
Process 1 is running in high priority queue
Process 1 finished execution
Process 2 is running in high priority queue
Process 2 is rescheduled with 18 remaining time
Process 3 is running in high priority queue
Process 3 is rescheduled with 28 remaining time
Process 2 is running in medium priority queue
Process 2 is rescheduled with 14 remaining time
Process 3 is running in medium priority queue
Process 3 is rescheduled with 24 remaining time
Process 2 is running in low priority queue
Process 2 is rescheduled with 6 remaining time
Process 3 is running in low priority queue
Process 3 is rescheduled with 16 remaining time
Process 2 is running in low priority queue
Process 2 finished execution
Process 3 is running in low priority queue
Process 3 is rescheduled with 8 remaining time
Process 3 is running in low priority queue
Process 3 finished execution
Process Duration Waiting Time Turnaround Time
110010
2201030
3303060
Average Waiting Time: 13.33
Average Turnaround Time: 33.33

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

What are the environmental impacts of mining and burning coal?

Answered: 1 week ago

Question

=+2. What different types of products exist in the book industry?

Answered: 1 week ago