time calculations
execution time - # of instructions * clock cycles for each * time per clock cycle
- if separate clock cycles per instruction, just compute total number of clock cycles separately
static frequency
- number of times an instruction appears in the compiled (written) code divided by total instructions
dynamic frequency
- number of times an instruction was ran divided by total # of ran instructions
speedup
old # clockc cycles / new # clock cycles
Exceptions, Traps, I
Synchronous - in sync with CPU Asynchronous - random times, usually external from CPU
Exceptions - usually not intentional, illegal behavior Traps - user accessing protected / privileged resources
Interrupts
Mode - ?
Handled by Kernel mode on the System stack
Exceptions squash instructions including the instruction that caused it
Interrupt Handler vs Macrostate
Handler
- save k0 on stack - save return address basically
- enable interrupts
- save CPU registers
- code
- restore registers
- disable interrupts
- restore k0 from stack - necessary bc what if many interrupts
- reti
Macrostate
- acknowledge device (INTA)
- save PC into k0
- get device’s address in IVT
- set as PC
- switch to system stack
Both
- disable interrupts
Pipelining
Opcode must be in each buffer, else other things that are needed in current stage / later stages
data forwarding
Basically bring the value back to the register needed! Results in no bubbles except for LW!!!
Branching
Conservative
If branch taken, 2 bubbles, else 1
Branch prediction
IF predicts correctly, no bubbles! else usually two since we flush IF and ID
Hazards
Data
- RAW
- WAW - output dependency
Control - non-sequential instructions (e.g. needing to flush if a BEQ was taken)
Structural - waiting til resources are free
Response Time Diagrams
how to get response time
count from 0 until process is handled
how to get wait time
count time not being I/O or on CPU before being completed
throughput / process
- throughput
- utilization
Scheduling algorithms
Preemptive - can kick processes off CPU (determines when time is done)
- SRTF
- has starvation (some processes may not be given any time for a while)
- Priority
- round robin
- limits starvation but needs a delicate balance between on the amount of time for each (too little time = too much overhead = wasted time)
non-preemptive - just runs one til finish, does not stop current process (no kicking)
- first come first serve (FCFS)
- SJF (shortest job first)
Solution to starvation = aging!
- priority: increase the process’s priority if x seconds in queue
- SRTF: override or set to next process if it has x seconds in queue