Quiz 1 solutions

  1. All machine architectures support an interrupt mechanism. What is the purpose of an interrupt? Give a concrete example of an interrupt in action.

    An interrupt alerts the CPU that some hardware device needs attention. For example, whenever you press or release a key on the keyboard, it sends an interrupt so the CPU can grab the scan code from the I/O port and put it in a queue for the current application.

  2. Why are there two separate modes of operation on a CPU (user mode and kernel mode)? What causes a switch from one mode to the other?

    The two separate modes help maintain a privilege separation – user mode is unprivileged and kernel mode is privileged. Because privileged instructions are banned in user mode, this prevents regular applications from taking over the system.

    A switch to kernel mode only occurs when handling an interrupt. The interrupt handler is part of the kernel, which then runs in kernel mode. It can switch back to user mode before resuming the interrupted process.

  3. What is the difference between a system call and a system program?

    I think the most direct answer here is that a system call is part of the application programming interface whereas a system program is part of the user interface.

  4. What is the purpose of the command interpreter (shell)? Why is it usually separate from the kernel?

    The shell is another essential part of the user interface. It interprets actions of the user (either text commands or graphical) as commands to be carried out by the OS kernel. It’s separate mainly for security and reliability. Since the kernel runs in privileged mode, we’d like to make it as small as possible. A shell does not need to be privileged, it just needs to make system calls to ask the kernel what to do.

comments powered by Disqus

 

©2012 Christopher League · some rights reserved · CC by-sa