Operating Systems CIS 657
Final Exam
Due: PDF file, codes, and one video file submitted by
Friday 3/26 at 11:00 PM EST
and Code/results presentation and questions on Monday 3/29 lecture time
Submission: PLEASE, READ CAREFULLY. Note: Any change in the submission format will cause
deduction of points. Final exam is an individual work not a team work.
1. A single pdf file that includes the following:
Codes of every file you edited highlighting in yellow the changes for all Questions in
addition to a screenshot of the output.
2. A zipped folder for the code for each question.
3. A single video file that shows short code overview and the output running for both questions.
Question 1: (88 points/100)
In this question, you are required to simulate the starving problem that a process may suffer if all other
processes in the system have higher priority than its priority.
It is required to create at least two processes (P1 and P2) with priorities 40 and 35 for example. You
should create a third process (Pstarv) with less priority such as 25.
You need to put P1 and P2 in the sleep state every couple of seconds to simulate a context switch
between P1 and P2. When P1 sleeps, P2 will run and when P2 sleeps, P1 will run. Until now, Pstarv will
not be able to run since its priority is the lowest priority. You need to fix that. You are required to
change/update/increase the priority of Pstarv each time a context switch occurs.
So, after a number of context switches, Pstarv will finally be able to run to print its ID and print a
celebration message that it is finally running and celebrate that you will get a good grade as well.
Feel free to assume any missing information such as should you have a flag or an argument to decide
which process you are interested to avoid starvation, should you use shell commands or not, should you
increase the Pstarv priority by 1 or by 5…..… etc.
P1 and P2 are not supposed to know anything about the Pstarv process. Do not hardcode it inside P1 or
P2. So, you should not include the code of increasing the Pstarv priority in P1 nor P2.
Question 2: (12 points/100)
You can think of the starvation problem in Question 1 but instead of incrementing the priority of the
Pstarv every time a context switch occurs, the priority increment of Pstarv should occur every two
seconds the Pstarv process is in the ready queue without getting the CPU.
To demonstrate this feature, you are required to just increment and print the “Pstarv priority” every two
seconds based on the clock and the clkinit (not the sleep function/system call).
FAQ Q1:
• Can I create more than three processes?
Yes
• Can I call them anything not necessary P1, p2, Pstarv?
Yes
• What should I do after Pstarv runs and prints its own ID and a celebration message?
Anything you want. You can terminate everything or you can keep working preventing
starvation for any other low priority process.
• Can I tell the OS that Pstarv is the one that should not be starved or let the OS finds out?
Anything. Bare min, you tell the OS. A better design is to let the OS finds out.
• Should I show that Pstarv priority increases each context switch?
Yes.
• Can I simulate the context switch using any other method not sleep P1 and P2 alternatively?
Yes.
• Sometimes, I see Pstarv running before its time, is it wrong?
Yes.
FAQ Q2:
• Can I use other time interval not 2 seconds?
Yes
• Can I combine the two questions and show both methods in one demo?
Yes
AssignmentTutorOnline