in Operating System edited by
21,640 views
67 votes
67 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
in Operating System edited by
21.6k views

4 Comments

 good doubt….See @arjun sir’s comment in below thread-

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.

So I think  privilege instruction can switch from kernel to  user mode(not necessary required  be privileged ) which is in the case of return from exception instruction. Return from exception is privilege instruction- this can be accepted as a  Fact.

correct me if wrong @arjun sir, @Bikram sir,

0
0
reshown by
with same logic option d can also be false as it is also not a necessity that instruction has to be non privileged to move from kernel to user mode
0
0

Shouldn’t both option B and D be the answer . Reason for B- to change from non privledge to privledge mode a software interrupt (system call) has to be generated. For example, lets say we have some data stored in memory and we want to output it. The memory will contact CPU via an interrupt which then shows the output to the user. 

Context switching with any non privledge instruction will also result in change of mode. Hence option B and D should be correct.

Please correct me if Im mistaken anywhere. 

0
0

4 Answers

75 votes
75 votes

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. 

http://web.cse.ohio-state.edu/~teodores/download/teaching/cse675.au08/CSE675.02_MIPS-ISA_part3.pdf

edited by
by

4 Comments

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.

1
1

@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

1
1
Adding to @Bikram Sir's answer.

Is there any situation when hardware interrupt is also needed?
0
0
2 votes
2 votes

Answer is (c)

Transitions from kernel to user mode are performed explicitly by the
operating system, generally at the end of an interrupt handler or
kernel call, using a privileged RFE (return from exception) instruction.

Ref- http://www.cs.rochester.edu/courses/252/spring2014/notes/08_exceptions

reshown by

1 comment

Correct me if I am wrong
0
0
1 vote
1 vote

To change from non privileged to privileged we require an interrupt known as software interrupt which is generated by a system call which gets translated into a privileged instruction. Option C would be apt.

Also The instructions that get executed in privileged mode will be privileged and never non-privileged. (The earlier answer which is supporting option D is having an absolutely wrong explanation)

reshown by

2 Comments

to change the mode from kernel mode to user mode ...only a bit(mode bit) is changed in register, nothing else is required

So no privileged instructions or interrupts are required.

Ans is D only
1
1
whattttt
1
1
0 votes
0 votes

option c

it is puerlly decision of the operating system in which particular mode instruction is executed . and operating system is always executed in kernal mode(privileged mode).

Answer:

Related questions