CPUs Microcode Protection and Protection Modes Flashcards
When CPU runs in Kernel mode, it can:-
- run any ___
- modify any ___ in ___
- access and modify any ___ in CPU and devices
- full control of the computer
instruction; location, memory; register
The OS services runs in ___ mode.
Kernel/User
Kernel
When CPU runs in User mode, it can:-
- use a limited set of ___
- modify only sections of ___ assigned to the process running the program
- access only ___, and cannot access ___ in ___
- limited access to the resources of the computer
instructions;
memory;
a subset of registers in CPU, registers, devices
The user programs run in ___ mode.
Kernel/User
User
Kernel/User Mode:
1. When the OS boots, it starts in ___ mode.
kernel
Kernel/User Mode:
2. In ___ mode, the OS sets up the ___ and ___ all the devices.
kernel, interrupt vector, initializes
Kernel/User Mode:
3. Then it starts the first process and switches to ___ mode.
user
Kernel/User Mode:
4. In ___ mode, the OS runs all the ___.
user, background system processes (daemons)
Kernel/User Mode:
5. Then it runs the ___ or ___.
user shell, windows manager
Kernel/User Mode:
6. While running in ___ mode, the program switches to ___ mode to request OS services (___).
user, kernel, system calls
Kernel/User Mode:
7. User programs also switch to ___ mode when ___ arrives.
kernel, interrupt
The interrupts are executed in kernel mode.
True/False
True
The interrupt vector can be modified in both kernel and user mode.
True/False
False. Only in kernel mode
Most of the CPU time is spent in __ mode.
User
Separation of user/kernel mode is for:-
___ (make sure user have enough privileges to run the call)
___ (Killing bugs and crashing)
___ (OS calling in kernel mode for fair access)
Security; Robustness; Fairness
If a process that tries to write to an invalid memory location, the OS will ___ the program, but the OS ___.
kill, continue to run
Which of the following is false?
A. A crash in the process will not crash the OS
B. A bug in user mode causes program to crash, OS will also crash
C. A bug in kernel mode may cause OS and system to crash
B.
A bug in user mode causes program to crash, but OS will still run.
An interrupt is an event that requires ___.
Little/moderate/immediate attention
immediate attention
In hardware, a device sets the interrupt line to ___.
low/medium/high
high
When an interrupt is received, the CPU will stop whatever it is doing and jump to the ___ that handles that specific interrupt.
Interrupt handler
After executing the handler, the CPU ___ and the program continues.
return to the same place where the interrupt happened
Arrange the steps of servicing an interrupt.
- 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
- CPU saves the program counter and registers in execution stack
- CPU looks up the corresponding interrupt handler in the interrupt vector
3, 4, 1, 2
Interrupts allow CPU and devices to run in parallel without waiting for each other.
True/False
True
Which of the following about poling is false?
A. Poling is also called “busy waiting”.
B. During poling, OS decides not to use interrupts for some devices and wait in a busy loop until completion.
C. Poling is used to print debug messages in the kernel.
D. Poling saves CPU cycles.
D.
Poling wastes a lot of CPU cycles.
Poling is called ___ processing since the execution of the device is ___ with the program.
synchronous, synchronous
An interrupt is also called ___ processing because the execution of the device is not ____ with the execution of the program.
asynchronous, synchronized
___ is an array of pointers that point to the different interrupt handlers of the different types of interrupts.
Interrupt vector
Interrupts run in kernel mode. Why?
An interrupt handler must read device/CPU registers and execute instructions only available in kernel mode.
Interrupt vector can be modified only in kernel mode.
True/False
True
Interrupt vector is initialized when drivers added to the system.
True/False
False.
Interrupt vector is initialized on bootup, and modified when drivers are added to the system.
Types of interrupts:-
____ is generated by devices when a request is complete or an event that requires CPU attention happens.
Devices interrupts
Types of interrupts:-
___ generated by the CPU when there is a math error.
Math exceptions
Types of interrupts:-
___ generated by the MMU (___) that converts virtual memory addresses to physical memory addresses.
Page faults; Memory Management Units
Types of interrupts:-
___ generated by software with a special assembly instruction.
Software interrupt
Match the reasons to their description for the MMU interrupt:-
___ : interrupt prompts a SEGV signal to the process.
___ : Access to a valid address but there is not page in memory. This causes the CPU to load the page from disk.
___ : (trying to write on a read only page) causes a SEGV signal to the process.
Invalid address;
Page not resident;
Invalid permission
System calls use ___.
software interrupts
Why do we use software interrupts for syscalls instead of function calls?
- Software interrupts will switch into ___ mode.
- OS services need to run in ____ mode because they need ___, accessing devices and ____, they need to enforce ___.
kernel; kernel; privileged instructions; kernel data structures; security in kernel mode
Only operations that need to be executed by the OS in kernel mode are part of the system calls.
True/False
True
Libc calls system calls directly.
True/False
False.
Libc provices wrappers for the system calls that eventually generate the system calls.
Which of the following about system calls is false?
A. The software interrupt handler for system calls has entries for all system calls.
B. The handler checks that the arguments are valid and that the operation can be executed.
C. The arguments of the syscall are not checked for quicker operations.
C.
The arguments of the syscall are checked to enforce the security and protections.
When an error in a system call occurs, the OS sets a global variable called ___ defined in libc.so with the ___ of the error that gives the reason for failure.
errno; number
Arrange the sequence of system calls and interrupt handler:-
- The OS in the interrupt handler checks the arguments. It verifies that fd is a file descriptor for a file opened in write mode, and [buff, buff+n] is a valid memory range. If any of the checks fail, write return -1 and sets errno to the error value.
- The interrupt handler puts the process calling write into ready state.
- The OS puts the current process in wait state until the disk operation is complete. The OS switches to another process.
- The User program calls the write(fd, buff, n) system call to write to disk.
- The Disk completes the write operation and generates an interrupt.
- The OS tells the hard drive to write the buffer in [buff, buff+n] to disk to the file specified by fd.
- The write wrapper in libc generates a software interrupt for the system call.
4, 7, 1, 6, 3, 5, 2