OS & Hardware
What is the main purpose of giving a CPU a privileged (kernel) mode and a user mode?
- ATo let application instructions run faster than, and ahead of, kernel instructions
- BTo prevent applications from tampering with page tables and devices
- 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.