User and Kernel Mode, Interrupts, and System Calls Flashcards
What happens when the cpu runs in Kernel mode?
● It can run any instruction in the CPU
● It can modify any location in memory
● It can access and modify any register in the CPU and
any device.
● There is full control of the computer.
What happens when the cpu runs in User mode?
●The CPU can only use a limited set of instructions
● The CPU can only modify only the sections of memory
assigned to the process running the program.
● The CPU can access only a subset of registers in the CPU
and it cannot access registers in devices.
● There is a limited access to the resources of the computer.
What services run in Kernal mode, which run in user mode?
OS services run in Kernel mode, user programs run in user mode
Does the computer boot up in Kernel or User mode?
● When the OS boots, it starts in kernel mode.
● In kernel mode the OS sets up the interrupt vector
and initializes all the devices, and kernel data
structures.
● Then it starts the first process and switches to user
mode.
True or False, programs runs in Kernel mode.
False, programs run in user mode
What is an interrupt?
An event that requires immediate
attention. In hardware, a device sets the interrupt line to high.
When do user programs switch to kernel node?
To request OS services (system calls). When an interrupt arrives.
Is most of the cpu time spent in Kernel or
User mode?
User mode
Are interrupts executed and (interrupt vectors) modified in Kernel or User mode?
Kernel mode
What are some reasons we separate User and Kernel mode?
Separation of user/kernel mode is used for:
● Security: The OS calls in kernel mode make sure that the
user has enough privileges to run that call.
● Robustness: If a process in user mode tries to write to an
invalid memory location, the OS will kill the process, but the
OS continues to run. A crash in the process will not crash
the OS. > A bug in user mode causes program to crash,
OS runs. A bug in kernel mode may cause OS and system
to crash.
● Fairness: OS calls in kernel mode to enforce fair access.
What is an interrupt?
An event that requires immediate
attention. In hardware, a device sets the interrupt line to high.
After the executing the interrupt handler what happens?
The CPU returns to place it was at before interrupt and the program continues.
When an interrupt happens, where does the cpu ‘jump’ to?
The cpu jumps to the interrupt handler to handle the specific interrupt.
What are some examples of interrupts?
Moving the mouse, typing a key, an ethernet packet
What are the specific steps of serving an interrupt?
- The CPU saves the Program Counter and registers
in execution stack - CPU looks up the corresponding interrupt handler
in the interrupt vector. - CPU jumps to interrupt handler and run it.
- CPU restores the registers and return back to the
place in the program that was interrupted. The
program continues execution as if nothing
happened. - In some cases it retries the instruction that was
interrupted (E.g. Virtual memory page fault
handlers).
How do interrupts allow the CPU and device to run In parallel without waiting for each other?
Device runs operations then ‘interrupts’ the OS. Then OS continues post interrupt.
What is polling?
The process instead of using interrupts where the OS waits in a busy loop until completion.