CS FundamentalsModerateWipro · Cognizant pattern
A system call interface lets a user program request a kernel service (like opening a file). What is the typical hardware-assisted mechanism that safely switches from user mode to kernel mode for this?
- A. Direct memory access (DMA) initiated by the user process
- B. A regular function call (CALL instruction) directly into kernel code
- C. A software interrupt / trap instruction, which switches the CPU to kernel mode and transfers control to a fixed kernel entry point (the trap/interrupt handler), rather than letting user code jump anywhere in the kernel
- D. Polling a kernel memory location in a busy loop until the kernel notices
Correct answer: C. A software interrupt / trap instruction, which switches the CPU to kernel mode and transfers control to a fixed kernel entry point (the trap/interrupt handler), rather than letting user code jump anywhere in the kernel
User code cannot be trusted to jump into arbitrary kernel addresses, so a trap instruction (e.g. syscall/int) is used: it is a controlled gate that always lands at a fixed, kernel-defined entry point and atomically raises the privilege level, unlike an ordinary call instruction which a user process could otherwise misuse.
More Operating Systems questions
- Copy-on-write (COW) is used after fork() to avoid copying the entire parent's address space immediately. How does it work?
- A process has a single-level page table with a 'valid/invalid' bit per entry. A memory reference to a page marked invalid causes a page…
- Memory-mapped files (via mmap) let a process treat a file's contents as part of its address space. Compared to read()/write() calls, what…
- Swap space (backing store) on disk lets the OS support more processes than fit entirely in physical RAM. Which statement about it is…
- RAID 5 stripes data across N disks and stores a rotating parity block (the XOR of the corresponding data blocks) on a different disk for…
- An array has 5 disks in RAID 5 (4 data + 1 rotating parity per stripe, effectively). Compared to plain striping (RAID 0) across the same 5…