The Gateway to Computer Science Excellence
+27 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 by
retagged by | 5k views
I am not sure, Why is it TRAP instruction ?

 Chhotu trap is an exception.. i think all the exception handling signals that are generated by the CPU control unit  can be called a TRAP SIGNAL..  correct me if i am wrong 

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

3 Answers

+22 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.


edited by
@ 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.
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.
Nowhere does the referenced link say that RFE is a trap instruction

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


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

+39 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
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.
0 votes

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)


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
52,345 questions
60,469 answers
95,272 users