The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+40 votes

A CPU has two modes -- privileged and non-privileged. In order to change the mode from privileged to non-privileged

  1. a hardware interrupt is needed
  2. a software interrupt is needed
  3. a privileged instruction (which does not generate an interrupt) is needed
  4. a non-privileged instruction (which does not generate an interrupt) is needed
asked in Operating System by Veteran (59.8k points)
edited by | 5.5k views
can anyone plz explain

"which does not generate an interrupt" why so?

1 Answer

+40 votes
Best answer

Answer should be (D). Changing from privileged to non-privileged doesn't require an interrupt unlike from non-privileged to privileged. Also, to loose a privilege we don't need a privileged instruction though a privileged instruction does no harm.

answered by Veteran (395k points)
edited by

@ruhul sharma 5

The mode bit is just a CPU register. It's only accessible if you're already in kernel mode.

First, see how we set the mode bit when we go from User mode to Kernel mode.

The details of how it gets set, depend on the CPU design. In most common hardware, it gets set automatically when executing a special opcode that's used to perform system calls. 

See here, it is not the kernel who set mode bit for himself to go into the kernel mode. It was automatically set through hardware by CPU.

You can read about this at here also. (2nd answer).

Now come to the kernel to user mode.

What I think.

A privileged instruction can set the mode bit to go to User mode from Kernel mode. And start executing the user instruction. There is no harm as the kernel has the access to the mode bit.

But it is not necessary. 

When we start executing a non-privileged instruction. Before its execution, the CPU detects it (as we did for system call by using opcode) and set the mode bit automatically.

As we can change mode bit with non-privileged instruction. D is the correct answer. Because we are not required to have a privileged instruction for it.


To loose a privilege, you don't need privilege  - this line sums up the answer beautifully.

What does it mean in context to this question??
is this the same as privileged and non-privileged execution modes in Linux?
switching from user mode to kernel mode do we require mode bit or software interrupt or hardware explain plz.
@bikram sir
Why option C is wrong?? As instruction can be privileged or non privileged also .
As u said mode bit can be changed by Some instruction
Why are these type of ambiguous questions asked in GATE in the first place? Clearly, both C and D are right.
You must first do Mathematical Logic portion well to do well in GATE. The instruction can be privileged but that is not a necessity. This makes C option FALSE but that does not mean the instruction should not be privileged.

The question really is who gets to modify the mode bit? Whether we consider the mode bit modification a privileged instruction or not?!?! What are the implications if we let the user modify the mode bit? When will we allow the user to modify it?

Let us allow the user to modify the mode bit. Now the problem that the mode bit tackles is so that the user doesn't execute any machine instructions. If we allow the user to modify, they can modify the mode bit and continue to execute a machine instruction at the user mode as the hardware might think it's the kernel who is executing the machine instruction as the mode bit is set to kernel mode. Now I maybe wrong because I don't know how this is implemented actually. I think that the explanations we've read so far from the books are simplified and it is a lot more complicated than that.

From what I understood, option C is the correct one. I may be wrong. I think that the modification of the mode bit is a privileged instruction. Because it will be impractical to allow the user to modify the mode bit no matter what mode it maybe be in.


@Arjun SIR u are synonym for authenticity for facts , we dont need to cross check the stuff u mentioned , and these are mostly CRUX of some topic . 

Just wanted to thank u


Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,068 questions
53,206 answers
70,419 users