in CO and Architecture retagged by
11,863 views
41 votes
41 votes

Which of the following must be true for the RFE (Return From Exception) instruction on a general purpose processor?

  1. It must be a trap instruction

  2. It must be a privileged instruction

  3. An exception cannot be allowed to occur during execution of an RFE instruction

  1. I only
  2. II only
  3. I and II only
  4. I, II and III only
in CO and Architecture retagged by
11.9k views

4 Comments

Here are my thoughts.. please give your rebuttals

1. why must it be a trap instruction? I find no reason that it has to be a trap. No referenced link in this post says it has to be a trap.

2. It has to be a privileged instruction because it accesses kernel stack in the newer OS. Although in older OS, there was no concept of kernel space and user space, it was one huge address space.

3. An exception cannot be allowed to occur? Aborts and faults (they are exceptions too) can occur during the execution of any instruction. It's like saying power failure is not allowed to happen when RFE is executing.

I think the answer should be II only
4
4
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.

 

I found this from the link

0
0
edited by
1
1

3 Answers

35 votes
35 votes
Best answer

RFE (Return From Exception) is a privileged trap instruction that is executed when exception occurs, so an exception is not allowed to execute. (D) is the correct option.

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

edited by

5 Comments

@ Vikrant : could you please cite some reference for your answer. Or else give some explanation as Why RFE is a privileged instruction because it is executed in Kernel mode. Secondly TRAP are software interrupts generated by user programs(synchronous interrupt) in order to change the level to more privileged or to execute an instruction that only OS can execute.

Please offer some explanation for this.
6
6
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.
10
10
Nowhere does the referenced link say that RFE is a trap instruction
2
2

exact use of the terms "interrupt", "exception", "trap", and "fault" varies from author to author and machine to machine

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

 

Maybe Statement I is true, because Statement II is true.

1
1

 the reference says that trap instructions are those instructions which r called by a program causing a system call. Since RFE is a system call (obviously since kernel to user mode can only be done by OS and thats what RFE does) and because the exception handler itself is a program hence we can say RFE is a trap instruction itself, 

Correct me if i am wrong.

0
0
59 votes
59 votes

As already told in other answers, RFE is a privileged trap instruction. The purpose of RFE is to switch from kernel mode to user mode once the system is done with handling an exception (any interrupt, trap or fault).

Now, let us approach this question through the points given.

  1. It must be a trap instruction - Definitely it must be a trap instruction as RFE is an explicit privileged instruction causing a switch from kernel to user mode

  2. It must be a privileged instruction - Yes, because RFE can be executed only in supervisor/kernel mode

  3. An exception cannot be allowed to occur during execution of an RFE instruction - Yes, because as soon as a trap/interrupt starts being processed all other traps/interrupts are disabled until the current instruction execution is complete.

So, all three are true and answer is (D)

edited by

4 Comments

edited by
I don't agree with your 3rd point. In priority based interrupt handling, while a lower priority interrupt is being serviced, if a higher priority interrupt happens, the higher priority interrupt will immediately get serviced.

The correct reasoning here is that RFE is an "instruction", so it is atomic. An exception is checked and executed only after the current instruction has finished executing.
1
1

Can someone refer this question https://gateoverflow.in/706/gate2001-1-13 and clear the doubt as to what is the correct answer. As both question’s answer are contradicting each other.

Privileged mode==kernel mode
Non privileged mode==user mode
From kernel to user mode, a non privileged instruction is required.
From user to kernel mode., a software interrupt is required.

This is given by @Bikram sir .

However,

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.

Source :– https://www.cs.rochester.edu/courses/252/spring2014/notes/08_exceptions

 

Can someone verify this and clear the doubt and contradictions both questions are creating.

@arjun Sir @Bikram Sir

2
2
i have same doubt as yours
0
0
I believe OPTION C is correct.
0
0
1 vote
1 vote

Trap is something that is requested by the program(syscall).

It is a privilege instruction and also while returning from interrupts we should have other interrupts to interrupt this process. so it must be disabled

so (D)

Answer:

Related questions