Returning from Interrupts and Exceptions
We will finish the chapter by examining the termination phase of interrupt and exception handlers. (Returning from a system call is a special case, and we shall describe it in Chapter 10.) Although the main objective is clear — namely, to resume execution of some program — several issues must be considered before doing it:
- Number of kernel control paths being concurrently executed
If there is just one, the CPU must switch back to User Mode.
- Pending process switch requests
If there is any request, the kernel must perform process scheduling; otherwise, control is returned to the current process.
- Pending signals
If a signal is sent to the current process, it must be handled.
- Single-step mode
If a debugger is tracing the execution of the current process, single-step mode must be restored before switching back to User Mode.
- Virtual-8086 mode
If the CPU is in virtual-8086 mode, the current process is executing a legacy Real Mode program, thus it must be handled in a special way.
A few flags are used to keep track of pending process switch
requests, of pending signals , and of single step execution; they are stored in the
flags field of the thread_info descriptor. The field stores other
flags as well, but they are not related to returning from interrupts and
exceptions. See Table
4-15 for a complete list of these flags.
Table 4-15. The flags field of the thread_info descriptor (continues)
Flag name | Description |
|---|---|
| System calls are being ... |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access