recategorized by
41,175 views
116 116 votes

Let the time taken to switch from user mode to kernel mode of execution be $T1$ while time taken to switch between two user processes be $T2$. Which of the following is correct?

  1. $T1 > T2$
  2. $T1 = T2$
  3. $T1 < T2$
  4. Nothing can be said about the relation between $T1$ and $T2$

6 Answers

Best answer
224 224 votes

Time taken to switch two processes is very large as compared to time taken to switch between kernel and user mode of execution because :

When you switch processes, you have to do a context switch, save the PCB of previous process (note that the PCB of a process in Linux has over $95$ entries), then save registers and then load the PCB of new process and load its registers etc. 

When you switch between kernel and user mode of execution, OS has to just change a single bit at hardware level which is very fast operation.

So, answer is: (C).

edited by
163 163 votes
Context switches can occur only in kernel mode. So, to do context switch first switch from user mode to kernel mode and then do context switch (save the PCB of the previous process and load the PCB of new process)

Context switch = user - kernel switch + save/load PCB + kernel-user switch

C is answer.
10 10 votes

Context switching can be described in slightly more detail as the kernel (i.e., the core of the operating system) performing the following activities with regard to processes (including threads) on the CPU: (1) suspending the progression of one process and storing the CPU's state (i.e., the context) for that process somewhere in memory, (2) retrieving the context of the next process from memory and restoring it in the CPU's registers and (3) returning to the location indicated by the program counter (i.e., returning to the line of code at which the process was interrupted) in order to resume the process.

Context switches can occur only in kernel mode. Kernel mode is a privileged mode of the CPU in which only the kernel runs and which provides access to all memory locations and all other system resources. Other programs, including applications, initially operate in user mode, but they can run portions of the kernel code via system calls.

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

0 0 votes

Switching from user mode to kernel mode ($T1$) is known as a mode switch, which happens during system calls, interrupts, or exceptions.

In a mode switch ($T1$), the execution shifts to kernel space within the context of the same process, meaning the memory mapping, page tables, and TLB remain completely unchanged.

Switching between two separate user processes ($T2$) is a full process context switch, which is a much more complex operation managed entirely by the operating system scheduler.

A process context switch ($T2$) requires saving the registers of the old process, loading the registers of the new process, switching the control of memory by changing address translation tables (page tables), and dealing with TLB invalidation.

Since a process context switch ($T2$) includes a change in memory management structures along with multiple mode switches to execute the scheduler code, it inherently takes significantly more overhead and time than a simple mode switch ($T1$).

Therefore, the time taken for a mode switch is strictly less than the time taken for a process context switch:

$$T1 < T2$$

Correct Option: C

–2 –2 votes
c As cs between processes involve loading processor state cpu registers into ram.
Answer:
Position:
Show:

Related questions

81 81 votes
4 answers 4 answers
28.3k
28.3k views
go_editor asked Sep 29, 2014
28,331 views
A thread is usually defined as a "light weight process" because an Operating System (OS) maintains smaller data structure for a thread than for a process. In relation to ...
59 59 votes
5 answers 5 answers
38.3k
38.3k views
go_editor asked Sep 29, 2014
38,270 views
Let the page fault service time be $10$ milliseconds(ms) in a computer with average memory access time being $20$ nanoseconds (ns). If one page fault is generated every $...
74 74 votes
4 answers 4 answers
24.1k
24.1k views
go_editor asked Sep 29, 2014
24,092 views
On a non-pipelined sequential processor, a program segment, which is the part of the interrupt service routine, is given to transfer $500$ bytes from an I/O device to mem...
47 47 votes
2 answers 2 answers
16.4k
16.4k views
akash asked Oct 29, 2014
16,424 views
Let $P$ be a regular language and $Q$ be a context-free language such that $Q \subseteq P$. (For example, let $P$ be the language represented by the regular expression $p...