http://proglit.com/. hardware and operating systems basics
TRANSCRIPT
• 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
instruction(a sequence of bits understood by the
processor to signal a certain action)
• copy bytes• arithmetic• bit logic• jumps
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
top of stack
top of stack
top of stack
top of stack
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
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)
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
(code periodically checks device registers to see if the device needs the CPU to do something)
polling
(code periodically checks device registers to see if they need the CPU to do something)
polling
1. device sends interrupt signal to CPU2. CPU saves state of whatever it was currently doing3. CPU jumps to address corresponding to interrupt
number in the interrupt table
interrupt
0x76 00 00 00interrupt 0
0x20 15 10 00interrupt 1
0x82 87 95 94interrupt 2
0xA2 22 00 10interrupt 3
0xFF 31 21 14interrupt 4
0xFF 31 01 11interrupt 5
0xFF 90 44 44interrupt 6
0xFF 31 01 11interrupt 7
… …
(code periodically checks device registers to see if they need the CPU to do something)
polling
1. device sends interrupt signal to CPU2. CPU saves state of whatever it was currently doing3. CPU jumps to address corresponding to interrupt number
in the interrupt table4. 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)
0x76 00 00 00exception 0
0x20 15 10 00exception 1
0x82 87 95 94exception 2
0xA2 22 00 10exception 3
0xFF 31 21 14exception 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
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
OS
device driver(plug-in to the OS to control a particular device)
device device device
driverdriverdriversoftware
hardware
1. CPU receives interrupt2. interrupt stores state of currently running code3. interrupt invokes handler4. interrupt handler invokes the scheduler5. scheduler selects a process6. scheduler “configures” CPU for that process7. scheduler jumps execution to that process
pre-emptive multitasking
0x76 00 00 00system call 0
0x20 15 10 00system call 1
0x82 87 95 94system call 2
0xA2 22 00 10system call 3
0xFF 31 21 14system call 4
0xFF 31 01 11system call 5
0xFF 90 44 44system call 6
0xFF 31 01 11system call 7
… …
stack
code0x 00 00 00 00
0x FF FF FF FF
heap
heap
allocated with system call
heap
heap
allocated with system call
allocated with system call
allocated with system call
HD
partition 1
partition 2
partition 3
HD
partition 4
flash drive
partition 5
CD-ROM
partition 6
partition 7
partition 1
/banana / /lemon/apple
/banana/adams/nixon/taylor/polk/hayes/lemon/apple/garfield
partition 2 partition 3