Revision - exceptions, virtual memory, cache etc Flashcards
two types of exceptions
internal - traps
external - interrupts
what is an exception
an event that disrupts the normal program flow
high level exception mechanism
- save address of current register
- transfer control to the OS at a known address
- handle the exception
- return to program execution
how is the address of the current register saved (exception mechanism)
use the EPC (exception program counter)
how is the exception handled (exception mechanism)
the exception handler is found
cause is dealt with
how is the program returned to program execution (exception mechanism)
restore user program registers
jump back using the EPC
this relies on eret
two approaches to finding the exception handler
- cause register
- vectored interrupt
cause register
jump to predefined address
use the cause register to branch to the right handler
vectored interrupt
jump directly to the specific handler depending on the exception
how is an exception dealt with (if restartable)
- determine the action needed
- inspect the cause register or opcode - take corrective action
- use the EPC (exception program counter) to return
how is an exception dealt with (if not restartable)
- determine the action needed
- inspect the cause register or defined opcode - terminate the program using the EPC (exception program counter)
what should happen to other interrupts whilst the exception is being dealt with (and how)
other interrupts should not occur
interrupts are masked by setting the EXL (exception level) in the status register
4 advantages of dual mode
- user programs do not have indefinite control
- ensures programs do not have access to resources which they do not have permission for
- ensures programs do not interfere with each other
- control is transferred to OS when user programs perform dangerous tasks
why are system resources protected
to provide safe and orderly access to resources (such as hardware and memory)
what is kernel mode
a mode where the OS takes control
it can only be accessed through exceptions
(the kernel is the nucleus of the OS)
differences between kernel and user mode
some instructions (such as accessing I/O devices and handling TLB misses) are only accessible in kernel mode
how is the current mode identified
a bit in special status register
how do you set the mode back to the previous mode
use eret
problems that CPU time sharing solves
- I/O takes too long - leaves the processor idle
- user programs can crash or use all of the CPU
How does CPU time sharing work
switch from one process to another when it performs I/O or when time allocation expires
what is the kernel
the core of the CPU that controls software and hardware resources
three active states
ready
running
blocked
five steps of process managing
- exception occurs
- process calls OS
- process info saved in PCB
- new process runs
- process states updated
(1. process calls the OS when interrupt / trap occurs
2. OS dispatcher performs a context switch
3. process info is saved in the Process Control Block (PCB)
4. Dispatcher chooses new process to run
5. process states are updated)
Two inactive states
suspended ready
suspended block
how does suspending and resuming processes occur
processes are moved from memory to disk.
the PCB (process control block) of inactive processes are kept in the OS
inactive processes may be resumed by returning data from disk to memory
what are 4 things contained in the PCB (process control block)
process id
process state
process priority
process permission
what is temporal locality
the tendency to reuse recently accessed data items
what is spatial locality
the tendency to reference data items that are close to other recently accesses items
how do memory hierarchies take advantage of temporal locality
by keeping more recently assessed data items closer to the processor
how do memory hierarchies take advantage of spatial locality
by moving blocks consisting of multiple continuous words in memory to upper levels of the hierarchy
how can the miss rate be lowered
by making larger blocks (which exploit spatial locality