• retagged by
18,051 views
56 56 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

4 Answers

Best answer
43 43 votes

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
81 81 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
2 2 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)

1 1 vote

In Computer Organization & Architecture (COA), RFE (Return From Exception) is a special, privileged instruction used by the Operating System (OS) to exit an exception handler and resume normal program execution, typically switching back to user mode from kernel mode after an interrupt or fault is handled. It's crucial for managing control flow, enabling interrupts again, and restoring the processor's state to where it left off before the exception occurred. 

Key Characteristics of RFE:

  • Privileged Instruction: Only the OS can execute RFE, as it controls system-level transitions.
  • Trap Instruction: It's part of the exception handling mechanism, designed to transfer control to the OS when an exception happens.
  • Restores State: Before executing RFE, the OS saves necessary registers; RFE restores these, including the program counter, to return to the interrupted instruction.
  • Enables Further Interrupts: It often re-enables interrupts, allowing the system to respond to new events after handling the current one.
  • Mode Switch: It facilitates the transition from kernel mode (where exceptions are handled) back to user mode (where the application runs). 

How it Works (Simplified):

  1. Exception Occurs: An event (like a page fault or system call) disrupts normal execution.
  2. Control to OS: The CPU saves the current state and jumps to the OS's exception handler (kernel mode).
  3. Handler Executes: The OS handler diagnoses the issue, performs necessary actions (e.g., loading a page into memory, servicing I/O).
  4. RFE Executed: The handler ends by executing RFE, which restores the saved state and resumes the user program. 
Answer:
Position:
Show:

Related questions

74 74 votes
4 answers 4 answers
35.7k
35.7k views
Kathleen asked Sep 12, 2014
35,654 views
Which of the following are NOT true in a pipelined processor?Bypassing can handle all RAW hazardsRegister renaming can eliminate all register carried WAR hazardsControl h...
47 47 votes
7 answers 7 answers
15.9k
15.9k views
go_editor asked Apr 23, 2016
15,851 views
Consider a machine with a $2$-way set associative data cache of size $64$ Kbytes and block size $16$ bytes. The cache is managed using $32$ bit virtual addresses and the ...
84 84 votes
10 answers 10 answers
29.0k
29.0k views
go_editor asked Apr 23, 2016
29,002 views
Consider a machine with a $2$-way set associative data cache of size $64$ Kbytes and block size $16$ bytes. The cache is managed using $32$ bit virtual addresses and the ...
79 79 votes
7 answers 7 answers
26.6k
26.6k views
go_editor asked Apr 23, 2016
26,578 views
Delayed branching can help in the handling of control hazardsThe following code is to run on a pipelined processor with one branch delay slot:I1: ADD $R2 \leftarrow R7 + ...