hardware and operating systems basics
BY SA
client/workstation (PC) server (responds to requests from network) hand-held (phone, audio player) embedded system (toaster, car) mainframe (a big server) supercomputer (a many-processor system)
RAM (Random Access Memory) addressable by the CPU volatile faster than storage code and data of running programs
programming model (simplified conception of a processor for sake of programmers)
instruction (a sequence of bits understood by the processor to signal a certain action) copy bytes arithmetic bit logic jumps
register (a small memory area in a processor) status general purpose
ISA (Instruction Set Architecture) x86 (IA-32, x86-64) ARM MIPS Motorola 68k
call stack (local variables) call stack (local variables) program memory heap (everything else) heap (everything else) code
frame of main frame of cat frame of dog frame of fish frame of bird frame of lama stack space local variables argument values top of stack
frame of moose stack space frame of main frame of cat frame of dog frame of fish frame of bird local variables argument values return address top of stack
big-endian vs. little-endian (the order in which the bytes of a register are copied from registers to memory and vice versa)
big-endian vs. little-endian (the order in which the bytes of a register are copied from registers to memory and vice versa)
processor registers processor cache random access memory hard drives speed, cost capacity
CPU registers device read/write
port-mapped I/O vs. memory-mapped I/O output register 2 to port 0x44 98 copy register 5 to address 0x66 2C 1A 32
ports memory addresses RAM 0x xFF FF FF FF byte 0 byte n port 0 port n devices
memory addresses RAM 0x x xFF FF FF FF 0x00 00 FF FF byte 0 byte n devices
(code periodically checks device registers to see if the device needs the CPU to do something) polling
CPU registers device interrupt line
(code periodically checks device registers to see if they need the CPU to do something) polling 1.device sends interrupt signal to CPU 2.CPU saves state of whatever it was currently doing 3.CPU jumps to address corresponding to interrupt number in the interrupt table interrupt
0x interrupt 0 0x interrupt 1 0x interrupt 2 0xA interrupt 3 0xFF interrupt 4 0xFF interrupt 5 0xFF interrupt 6 0xFF interrupt 7 ……
(code periodically checks device registers to see if they need the CPU to do something) polling 1.device sends interrupt signal to CPU 2.CPU saves state of whatever it was currently doing 3.CPU jumps to address corresponding to interrupt number in the interrupt table 4.CPU returns to whatever it was doing before the interrupt interrupt
hardware exception (a condition which causes the CPU to jump to a pre-determined address) 0x exception 0 0x exception 1 0x exception 2 0xA exception 3 0xFF exception 4 ……
Instruction Set Architecture byte size word size address size cache speeds and sizes big-endian vs. little-endian ports vs. memory-mapped i/o number of processors/cores
boot firmware CPU registers BIOS
boot firmware CPU registers BIOS
operating system (manages the hardware and running programs) load and manage processes provide “interfaces” to hardware via system calls provide a filesystem provide a basic user interface
Windows (series of OS’s from Microsoft) Windows 7 Windows Server 2008 Windows CE
Unix (a family of OS’s) Linux BSD OS X
OS device driver (plug-in to the OS to control a particular device) device driver software hardware
B B A A B B C C C C B B A A B B A A time A A B B C C B B C C A A C C C C CPU CPU 2 process OS
1.CPU receives interrupt 2.interrupt stores state of currently running code 3.interrupt invokes handler 4.interrupt handler invokes the scheduler 5.scheduler selects a process 6.scheduler “configures” CPU for that process 7.scheduler jumps execution to that process pre-emptive multitasking
Process C Process B OS Process A 0x xFF FF FF FF
stack heap code 0x x FF FF FF FF heap RAM byte 0 byte n
stack heap code 0x x FF FF FF FF heap RAM byte 0 byte n HD
Process C Process B OS Process A jump to system call code via special instruction RAM
0x system call 0 0x system call 1 0x system call 2 0xA system call 3 0xFF system call 4 0xFF system call 5 0xFF system call 6 0xFF system call 7 ……
stack code 0x x FF FF FF FF heap allocated with system call heap allocated with system call
stack code 0x x FF FF FF FF heap deallocated with system call
stack code 0x x FF FF FF FF top of stack stack boundary heap
stack code 0x x FF FF FF FF top of stack stack boundary heap
created waitingrunning blocked terminated
HD partition 1 partition 2 partition 3 HD partition 4 flash drive partition 5 CD-ROM partition 6 partition 7
file 35 file 7 file 61 file 3 directory 21 directory 86 root directory
partition 1 C:H:H:D:D: C:/ H:/ D:/ partition 2 partition 3
partition 1 C:H:H:D:D: C:/adams/nixon H:/taylor/polk/hayes D:/garfield partition 2 partition 3
partition 1 /banana//lemon/apple partition 2 partition 3
partition 1 /banana//lemon/apple /banana/adams/nixon /taylor/polk/hayes /lemon/apple/garfield partition 2 partition 3
IPC (Interprocess Communication) files pipes sockets signals shared memory