5,206 views
1 votes
1 votes
Out of the following actions by a process running on a system the actions (i) (fill ALL possible correct choices) will always result in a context switching out of the running process. (a) Servicing an interrupt. (b) A blocking system call. (c) A non-blocking system call. (d) The system call exit, to terminate the current process.

3 Answers

Best answer
1 votes
1 votes

In all four cases, a context switch may occur, but it is not necessary for the scheduler to perform a context switch in these scenarios. Since the question asks 'always', the answer would be none of the above. Reference http://csapp.cs.cmu.edu/ Chapter 8 of the book.

selected by
5 votes
5 votes
The questions asks in which scenarios a context switch will ALWAYS occur:

(a) Servicing an interrupt.

The kernel services the Interrupt on behalf of the running process only, it just switches the stack from Process Stack to Kernel stack. If the Interrupt is from System clock then there "MIGHT" be a context switch if the running process has exhausted the time quantum alloted to it. Otherwise there will be no context switch. Similarly for Interrupts, it may or may not context Switch.

(b) A blocking system call

A blocking system call is issued when the process wants some data from the disk or over the network. Typically there are very slow task and there is no point in waiting for them to finish, hence the CPU will switch to another process meanwhile the disk or network operation is going on. Hence, it will Context Switch.

(c) A non-blocking system call.

A non blocking system call, will not context switch, as the process has issued a command but it does not wait for it to finish. It carry on with its work and will get the result back in form of some callback function. Hence it will NOT context switch.

(d) The system call exit, to terminate the current process.

It has to context switch as the process has been terminated.
0 votes
0 votes
for all the options given in the question,the context switching will be done.for option a,servicing an interrupt it requires to run interrupt service routine.for this context switching will be done.now the options b,c,d all are about system calls.so for executing system calls it needs to go to superuser mode from user mode.so for all of them context switching will be resulted

Related questions

0 votes
0 votes
1 answer
2
0 votes
0 votes
0 answers
3