Question: Question 2 - Context Switch ( 2 2 points ) ( This question is related to ILO 2 - explain the principles behind the core

Question 2- Context Switch (22 points)
(This question is related to ILO2- "explain the principles behind the core function: Process Management",
and ILO4- "demonstrate knowledge in applying system software and tools".)
Consider a single-core computer with only 2 user processes P1 and P2. The OS employs a
priority-based scheduling policy and selects the process of the highest priority to run whenever it
has a chance to schedule. P1 has a higher priority than P2. Assume P1 is currently running and P2
is in the ready queue. Further assume the machine doesn't have a timer device for timer interrupts
and all the system calls are successful. Answer the following questions.
Consider that P1 makes a system call to read a file from the disk. Describe the major OS
behaviors from when the system call is made to the time when the call completes and returns.
Write down the key events (e.g., mode switches, context switches, etc) as bullet points.
Assume P 2 is a process with the following pseudo code. When P 2 is scheduled to run, what
would be the possible resulting values of x upon the completion of P2? Please explain your
answer.
int x =0;
void func1(void)
{
for (int k =0; k 10; k++)
x++;
}
int main()
{
x++;
int pid = fork();
func1();
return 0;
}
Following 2) and given the above settings, do you think P 2 would run to completion without
being de-scheduled once it starts executing on the CPU (i.e., the first time it is scheduled)?
Why or why not?
Question 2 - Context Switch ( 2 2 points ) ( This

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!