Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE LOOK AT PICTURE. USE C CODE! Question 2: Simulating a Multi Level Scheduler Write a C program that will simulate the operation of a

image text in transcribedimage text in transcribed

PLEASE LOOK AT PICTURE. USE C CODE!

Question 2: Simulating a Multi Level Scheduler Write a C program that will simulate the operation of a kernel with two-level-scheduler (short term and long term) using the Pthread library. The main program (kernel) will have two threads, each representing one of the two schedulers (implemented in code as two separate functions). There will be two Queues (ue the Linux data structures from chapter 1): ready queue and new queue. Also, implement a struct with two elements: PID (unique ID of process) and Time (total execution time of process) At the start of the program, populate the new Queue with 100 processes. For each process, auto increment (staring from 1) the PID and randomly select Time (in the range 1-30). Then create the two threads for the two schedulers. Now invoke the long-term scheduler Long-term scheduler method will dequeue an element (process) from the new queue and enqueu into the ready queue. However, the ready queue has marimum length 5. In this method, display suitable logging message to the screen i.e. start, action, stop. Long-term scheduler will pass the control to short-term scheduler. The short-term scheduler method will dequeue an element (process) from the ready queue, reduce its time by two, enqueu it to the ready queue. It will repeat this process five times and then pass the control to the long-term scheduler. If the Time of a certain element (process) reaches zero then it will be permanently removed from the ready queue. Also, in this method, display suitable logging message to the screen i.e. start, action, stop. The program will end when all the elements have zero Time left. #2-A: Write type your source code in your submission file document. Also, submit the .c file separately #1-B: In your submission file document, add a screenshot which displays the execution of your progranm Question 2: Simulating a Multi Level Scheduler Write a C program that will simulate the operation of a kernel with two-level-scheduler (short term and long term) using the Pthread library. The main program (kernel) will have two threads, each representing one of the two schedulers (implemented in code as two separate functions). There will be two Queues (ue the Linux data structures from chapter 1): ready queue and new queue. Also, implement a struct with two elements: PID (unique ID of process) and Time (total execution time of process) At the start of the program, populate the new Queue with 100 processes. For each process, auto increment (staring from 1) the PID and randomly select Time (in the range 1-30). Then create the two threads for the two schedulers. Now invoke the long-term scheduler Long-term scheduler method will dequeue an element (process) from the new queue and enqueu into the ready queue. However, the ready queue has marimum length 5. In this method, display suitable logging message to the screen i.e. start, action, stop. Long-term scheduler will pass the control to short-term scheduler. The short-term scheduler method will dequeue an element (process) from the ready queue, reduce its time by two, enqueu it to the ready queue. It will repeat this process five times and then pass the control to the long-term scheduler. If the Time of a certain element (process) reaches zero then it will be permanently removed from the ready queue. Also, in this method, display suitable logging message to the screen i.e. start, action, stop. The program will end when all the elements have zero Time left. #2-A: Write type your source code in your submission file document. Also, submit the .c file separately #1-B: In your submission file document, add a screenshot which displays the execution of your progranm

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