IEEE 754 · single precision
How a 32-bit float is stored
Sign + biased exponent + mantissa. Practice converting bits → decimal in 30 seconds.
value = (−1)ˢ × 2^(E − 127) × (1 + F)
S sign bit (1 bit)
E biased exponent (8 bits, bias 127)
F mantissa (23 bits, fractional)
HDD average access time
Four delays, summed.
Reading one block from a spinning disk is the sum of four independent waits. Knowing each component is what gets tested.
total = seek + controller + rotational latency + transfer
rotational latency = ½ × (60 / RPM) seconds
transfer time = block_size / rate seconds
Why ½ on rotation
A full rotation takes 60/RPM seconds. On average the sector is half a rotation away — sometimes right there, sometimes a full turn out. Mean = half a rotation.
MIPS
CPU speed metric
Million instructions per second.
MIPS = clock_MHz / CPI
Cache effective access
Average memory time
Hit rate weights the two paths.
T = h·t_cache
+ (1−h)·t_main
PERT estimate
Three-point duration
Most-likely is weighted heavier.
O + 4M + P
6
Series availability
All must work
Availability multiplies down. Adding parts hurts.
A = A₁ × A₂ × … × Aₙ
Parallel availability
At least one must work
Compute the chance all fail, then flip it.
A = 1 − (1 − A)ⁿ
SLA max downtime
How long you can be down
Service hours times your error budget.
downtime = service_hrs
× (1 − target)
Straight-line depreciation
Even value drop per year
Each year drops by the same amount.
annual =
cost − salvage
useful_life
Scheduling
Scheduling metrics
Three ways to measure a scheduler
| Metric | Definition | Unit | Direction |
| Throughput | Processes done per unit time | jobs / sec | Higher is better |
| Turnaround | Arrival → completion (wait + burst + I/O) | seconds | Lower is better |
| Response time | Arrival → first CPU allocation | seconds | Lower is better |
turnaround = waiting + burst (CPU-only)
waiting = turnaround − burst
response ≤ turnaround (always)
Trap
Response is the wait until
first execution. Turnaround includes everything until
completion. They diverge in preemptive schedulers where a job starts, pauses, then finishes much later.
FCFS · first come first served
The simplest scheduler
Run whoever arrived first to completion. No preemption. Easy by hand.
completion(i) = arrival(i) + waiting(i) + burst(i)
turnaround(i) = completion(i) − arrival(i)
waiting(i) = turnaround(i) − burst(i)
avg turnaround = Σ turnaround(i) / n
avg waiting = Σ waiting(i) / n
Convoy effect
One long job at the front of the queue makes everyone wait. FCFS performs badly when burst times vary a lot.
FCFS · worked example
Three processes, all arrive at time 0
Run in arrival order, no preemption. Bursts: P1=8, P2=4, P3=2.
| Process | Burst | Wait | Turnaround |
| P1 | 8 | 0 | 8 |
| P2 | 4 | 8 | 12 |
| P3 | 2 | 12 | 14 |
·
Avg wait = (0 + 8 + 12) / 3 = 6.67
·
Avg turnaround = (8 + 12 + 14) / 3 = 11.33
Compare with SJF
P3 only needs 2 units but waits 12. If we'd run shortest-first (P3 → P2 → P1), avg wait drops to
(0 + 2 + 6) / 3 = 2.67. That's why SJF beats FCFS on average.
Misc
Permutations · nPr
Order matters
Pick r items from n where arrangement counts — first/second/third are different outcomes.
ⁿPᵣ =
n!
(n − r)!
Example
Race with 5 runners, how many ways to fill gold/silver/bronze?
⁵P₃ = 5! / 2! = 60.
Combinations · nCr
Order doesn't matter
Pick r items from n where you only care which were chosen, not the order.
ⁿCᵣ =
n!
r! × (n − r)!
Example
Pick a 3-person committee from 5 people.
⁵C₃ = 5! / (3! × 2!) = 10. nCr is always smaller than nPr by a factor of
r!.
Group probability
k items adjacent in n slots
P =
(n − k + 1)! × k!
n!
Bit-shift × tricks
Multiply by shift + add
9n = (n<<3) + n
7n = (n<<3) − n
5n = (n<<2) + n
3n = (n<<1) + n
Defect cost expected value
The chain of multiplications
Multiply down the funnel — total → defective → discovered → in this category → cost each.
EV = size × defect_rate × discovery_rate × category_share × cost_per_defect
Cryptography
Key types · symmetric vs asymmetric
One key or two?
Symmetric uses one shared secret for both encrypt and decrypt — fast, but you have to get the secret to the other party safely. Asymmetric (public-key) uses a key pair — what one key locks, only the other can unlock. Slower, but solves the key-distribution problem.
| Type | Keys | Speed | Use case | Examples |
| Symmetric | 1 shared | Fast | Bulk data encryption | AES, DES, 3DES |
| Asymmetric | 2 (public + private) | Slow | Key exchange, signatures | RSA, ECC, DSA |
| Hash | 0 (one-way) | Fast | Integrity, fingerprints | SHA-256, MD5 |
In practice · the hybrid trick
TLS / HTTPS uses both. Asymmetric to
exchange a session key safely, then symmetric to encrypt the actual conversation. You get the key-distribution benefit of asymmetric and the speed of symmetric.
Public-key · which key when
Two opposite uses
Confidentiality
- Encrypt
- Receiver's public
- Decrypt
- Receiver's private
Signature
- Sign
- Sender's private
- Verify
- Sender's public
Memory hook
The
private key always belongs to the person doing the secret thing — opening their own mail, signing their own document. The
public key is for everyone else.
RSA · inventors
Three names, one acronym
Published in 1977 at MIT. The acronym is just their surnames in order.
- R
- Ron Rivest
- S
- Adi Shamir
- A
- Leonard Adleman
How it works
Security relies on the difficulty of factoring the product of two large primes. Easy to multiply, brutally hard to reverse — that asymmetry is the whole trick.