OS & Hardware

What is the main purpose of giving a CPU a privileged (kernel) mode and a user mode?

  1. ATo let application instructions run faster than, and ahead of, kernel instructions
  2. BTo prevent applications from tampering with page tables and devices
  3. CTo let one CPU execute two instructions at the same time
Show answer and explanation

Answer: B. To prevent applications from tampering with page tables and devices

If applications could freely rewrite page tables, operate I/O devices or disable interrupts, they could corrupt other programs' memory or halt the whole system. CPUs therefore allow these operations only in privileged mode, reserving them for the OS kernel; attempting them in user mode raises an exception. The modes are not about speed or simultaneous execution.

  • A. Execution speed does not depend on the mode.
  • B. Correct. Dangerous operations are reserved for the kernel to protect the system.
  • C. Executing multiple instructions at once is the job of superscalar designs and the like.
Practice this topic Back to topic

More OS & Hardware questions

  1. What is the mechanism by which applications ask the OS to perform tasks such as file I/O?
  2. What happens when the ecall instruction at the end of the RISC-V code above executes?
  3. Which is the usual distinction between interrupts and exceptions?
  4. Which of the following is asynchronous, occurring at unpredictable times unrelated to the instruction being executed?
  5. What is the usual sequence when a CPU accepts an interrupt?