2,956 views
14 votes
14 votes
Assume that current cpu burst of the lone process spans more than one time-slice of the round-robin algorithm.

My reasoning is as below

The steps that may take place when a timer interrupt occurs in a typical case are

1. Interrupt occurs.
2. Switch to kernel mode
3. OS saves current context into PCB(save registers, process state and memory-management info of current process)
4. Perform many architecture-specific operations, including flushing data and instruction caches and TLB's.
5. Put current process into the ready queue
6. Choose the new process to execute
7. Load context from the PCB of that process
8. Switch to user mode. Start executing the new process

I am now thinking that the OS might as well inspect the ready queue first and check if there are other processes. If there aren't any there is no need for a context switch. Thus handling of the timer interrupt will entail switching between the user mode and kernel mode, checking the ready Q, and switching back to the user mode to resume execution of the process.

Is this what happens? Or does a proper context switch of involving the unnecessary saving of the current state of the lone process and the restoring the same take place?





this question arises because der is a question in ISRO exam 2007..
which of the following not necessarily saved at the time of context switching ?
a. Program Counter
b. TLB
c. General Purposes Register
d. Stack Pointer

and correct answer was given as TLB ..
reason is when context switch takes place between two threads of same process TLB and Cache are still valid because both thread are of same process .. so dont save (dont even flush) TLB and Cache at the time of Context switching..

1 Answer

Best answer
18 votes
18 votes

You should see the word "NECESSARILY" in question. We don't need to save TLB or cache the ensure correct program resumption. They are just bonus for ensuring better performance. But PC, stack and registers MUST be saved as otherwise program cannot resume. 

Ref: http://www.linfo.org/context_switch.html

selected by

Related questions

0 votes
0 votes
0 answers
1
Piyush151099 asked Dec 1, 2018
251 views
1 votes
1 votes
0 answers
2
anisha007 asked Sep 25, 2018
739 views
What is the least number of context switching required for 'n' number of processes?