User Mode, Kernel Mode, Interrupts and System Calls Flashcards
What architecture do modern computers use? Where are the programs and data stored?
Von Newman. Stored in ram.
How is data transferred from CPU, to RAM, ROM and devices?
Through the address and data bus.
What can a service do in Kernel mode?
Can run any instruction, modify any location in memory, can access any register.
What mode to OS services run in? Kernel or User?
Kernel, they need full control.
What can a service do in User mode?
CPU can use limited instructions, limited sections of memory, limited registers.
What happens with the modes when the OS boots?
It boots in Kernel mode to set up interrupt vectors and more. After starting the first process it moves to User mode.
When to programs switch from User to Kernel mode?
When an interrupt arrives.
Is more CPU time spent in User or kernel mode?
User
Why are user and kernel mode separated?
Security, Robustness (crash in user doesn’t kill os), and Fairness
If a bug occurs in Kernel mode can the os crash?
Yes
What happens during an interrupt?
Hardware sets interrupt line to high, CPU jumps to interrupt handler, then returns to previous spot.
What are some examples of interrupts?
move mouse
type key
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 the
instruction that was interrupted (E.g. Virtual
memory page fault handlers).
- The CPU saves the Program Counter and
What is polling in the context of handling tasks?
when the OS waits in a busy loop instead of using interupts.
What is Synchronous vs Asynchronous processing?
Polling is synchronous. Interrupt is asynchronous.
What is the interrupt vector?
It is an array of pointers that point to the different interrupt handlers of the different
types of interrupts.
What are a couple of interrupt handlers?
Hard Drive Interrupt handler
USB Interrupt handler (mouse, kbd)
Ethernet Card Interrupt handler
Page Fault Interrupt handler
Why must interrupts be handled in Kernel mode?
Instructions needed only available in Kernel mode.
What are the different types of interrupts?
Device Interrupts, Math exceptions, Page Faults, Software Interrupt
What is a system call?
How programs request services from the OS.
What are some examples of system calls?
◼ open(filename, mode)
◼ read(file, buffer, size)
◼ write(file, buffer, size)
◼ fork()
◼ execve(cmd, args);
Why are software interrupts needed for system calls?
Need Kernel mode for OS services
Do all parts of the system call run in Kernel mode?
No, ex: for malloc most of it runs in user mode until sbrk() is called to extend the heap.
What library provides wrappers for system calls?
Libc