Question: , Question 2 [ 2 0 Marks ] ( a ) In our kemel, context switching begins when the current running process calls tswitch (

, Question 2[20 Marks]
(a) In our kemel, context switching begins when the current running process calls tswitch(), which changes the execution to a new process. Some people refer to this as a co-routine call, not a complete context switching. To soothe such critics, we may implement tswitch () as
```
_tswitch:
INT 100
ret
```
When the x86 CPU executes the INT 100 instruction, it first saves the CPU's [FLAG, CS,\(\mathrm{PC}]\) registers onto the (current) stack. Then, it loads the contents of the memory locations [400,402] into CPU's [PC, CS], causing it to execute from the newly loaded [PC, CS]. Corresponding to INT 100, the instruction IRET pops 3 items into the CPU's [PC, CS, FLAG] registers. If the memory contents of [400,402]=[SAVE,0x1000]. Then, after INT 100, the CPU would execute SAVE in our kernel.
Justify whether it is necessary to implement context switching this way,
(b) Assume that a process P has executed the following function calls:
Draw a diagram showing the stack contents of \( P \) when execution is at the label HERE in function 3(). Clearly show the stack frames of each function together with locations of FP and SP.
Question 3[20 Marks]
Assume: In our kernel, P1 is a Casanova process, which hops from segment to segment. Initially, P1 runs in the segment \(0\times 2000\). By a hop (\( u 16\) segment) syscall, it enter kemel to change segment. When it returns to Umode, it returns to an IDENTICAL Umode image but in a different segment, e.g.\(0\times 4000\).
(a) Devise an algorithm for the hop () syscall.
(b) When a Casanova process tries to change its Umode segment, the target segment may already be occupied by another process. If so, the original process must be evicted to make room for the Casanova process. Devise a technique that would allow the Casanova process to move into a segment without destroying the original process in that segment.
, Question 2 [ 2 0 Marks ] ( a ) In our kemel,

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!