arch-lab CPU · memory · processes · networks

1. The fetch–decode–execute cycle

A tiny CPU running a small program. Watch the datapath move data between the PC, memory, the IR, the registers and the ALU on every clock tick. Each instruction passes through fetch → decode → execute → write-back.

phase
PC0
IR
R0 R1 R20 0 0

2. Number representation & two's complement

A value shown as bits in a fixed register width. Read it in binary, octal and hex, and toggle two's-complement to see how negatives are encoded: $-x \equiv 2^{w} - x \pmod{2^{w}}$, where the top bit carries weight $-2^{w-1}$.

binary
octal
hex

3. Direct-mapped cache

An address splits into tag · index · offset. Each access checks the line at its index: a hit if the tag matches, otherwise a miss that loads a block from memory. Replay an access pattern and watch the hit rate climb as blocks warm up.

address bits
hits / misses0 / 0
hit rate

4. Virtual memory & paging

A virtual address is page number · offset. The page table maps each virtual page to a physical frame (or marks it not-present → a page fault). Translation: $\text{phys} = \text{frame} \times 2^{o} + \text{offset}$ for offset width $o$.

page · offset
frame
physical addr

5. CPU scheduling — Gantt charts

Five processes with arrival and burst times. Compare FCFS, shortest-job-first and round-robin. The Gantt chart and the average waiting / turnaround times update from the chosen policy.

avg waiting
avg turnaround

6. Process life cycle

A process moves through new → ready → running → waiting → terminated. Trigger events — dispatch, timer interrupt, I/O request, completion — and watch the scheduler move the process between states.

statenew
last event

7. Deadlock — resource allocation graph

Processes (circles) hold and request resources (squares). A cycle in the allocation graph with single-instance resources means deadlock. Click a process then a resource to toggle a request edge; the cycle detector runs live.

edges0
cycle
deadlocked

Click P then R: P requests R. Click R then P: R is assigned to P.

8. OSI / TCP-IP layers & encapsulation

Data travelling down the stack gets wrapped by each layer in its own header; the receiver peels them back off. Step the packet down the seven OSI layers (or the four TCP/IP layers) and see the headers stack up.

at layer
PDU name

9. IPv4 addressing & subnetting

An IPv4 address with a CIDR prefix /p. The mask splits it into a network part and a host part. A /p network has $2^{32-p}$ addresses and $2^{32-p}-2$ usable hosts (minus network & broadcast).

mask
network
broadcast
usable hosts

10. TCP three-way handshake

Before any data flows, TCP opens a connection with SYNSYN-ACKACK, exchanging initial sequence numbers. Step through it and watch each endpoint's connection state change. UDP, by contrast, just sends.

client stateCLOSED
server stateLISTEN
last segment

11. Ports, protocols & the socket

A socket is an IP : port pair. Well-known services live on reserved ports (0–1023); clients use ephemeral ports. Pick a service to see its port, transport and where it sits — and how a full connection is identified by the 4-tuple.

port
transport
range
4-tuple