Starting from:
$35

$29

Programming Assignment 2 Solution

Objectives




Learn the process and thread life cycle



Learn how to use Linux system calls related to processes and threads



Learn how multi level scheduling works



Submission Requirements




Please submit your results/output in the solution template provided.




The questions that involve performing task on the computer, your answer will be the screen shot of your steps; writing the answer in the text form is not acceptable.




The questions that involve coding/script, you have to write your code/script in text form in the document.




Also, separately upload the source code (.c etc.) files.







Assignment Requirements and Setup




You are required to perform the tasks in a Linux environment using C/C++ language. Before starting the tasks, first change your command prompt as discussed earlier. As a result, make sure that you see your Student ID in command prompt every time you write a new Linux command.










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 (use 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.
















LE/EECS 3221 2



Long-term scheduler method will dequeue an element (process) from the new queue and enqueu into the ready queue. However, the ready queue has maximum 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 program




































































































































LE/EECS 3221 3

More products