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?

  1. A. Direct memory access (DMA) initiated by the user process
  2. B. A regular function call (CALL instruction) directly into kernel code
  3. 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
  4. 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

Exams that ask this topic