System Call Test Qs Flashcards
Chapter 6 of Operating Systems: Three Easy Pieces
What is the primary purpose of the trap table during the OS’s initialization?
maps two things to kernel handlers
The trap table maps system call numbers and trap types to the appropriate kernel handlers. During initialization, the OS sets up the trap table to define how to handle various exceptions, system calls, and interrupts
Which statement best describes the execution of a user process in user mode?
In user mode, a user process runs with restricted access to system resources, relying on system calls to request kernel services. It cannot directly access hardware or execute privileged instructions
What are the two main steps a user process takes to initiate a system call?
instruction and process’s info
The user process executes a ‘trap’ instruction to switch from user mode to kernel mode. Then, the process places the system call number and its arguments in predefined registers or memory locations for the kernel to process.
During the mode switch from user to kernel, what actions occur?
C, K, Th
- CPU changes from user to kernel mode to grant process privileged access.
- Kernel saves the user process’s context, like program counter, stack pointer
- Trap handler is executed based on the system call number or trap type
How does the CPU use the trap table during a system call to transfer control to the operating system kernel?
pointers to routines … addresses to handlers to control
The trap table contains pointers to specific kernel routines. When a system call or trap occurs, the CPU consults the trap table to find the address of the corresponding handler and transfers control to it
What types of information are saved by the OS kernel in the process’s kernel during context saving?
The user process’s program counter, current registers, user stack pointer, any additional status information required to restore the process later
How does the OS kernel determine which specific call handler to execute?
something used as an index in a table
The system call number provided by the user process is used as an index into the trap table to locate the corresponding handler function
What is an example of a privileged operation that might be performed during a system call?
memory, processes, hardware, file systems
Allocating or managing free memory, modifying process scheduling, accessing hardware devices, managing file systems
What is the purpose of the “return from trap” instruction in the system call process?
3 things
It restores the saved user context, switches the CPU back to user mode, and resumes execution of the user process at the instruction following the system call
After a system call is completed and control is returned to the user process, what typically contains the results of the system call?
a predefined register or memory locations accessible to the user process