proglit
DESCRIPTION
http:// proglit.com /. hardware and operating systems basics. SA. BY. 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). - PowerPoint PPT PresentationTRANSCRIPT
http://proglit.com/
hardwareand
operating systemsbasics
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
http://proglit.com/
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)ARMMIPSMotorola 68k
http://proglit.com/
call stack(local variables)program memory
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
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)
http://proglit.com/
processor registersprocessor cache
random access memoryhard drives
speed, cost
capacity
http://proglit.com/
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
0x00 00 00 00
0xFF FF FF FF
byte 0
byte n
port 0
port n
devices
memory addresses
RAM
0x00 00 00 00
0x00 01 00 00
0xFF 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
deviceinterrupt line
(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
… …
http://proglit.com/
• 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
http://proglit.com/
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
http://proglit.com/
OS
device driver(plug-in to the OS to control a particular device)
device device device
driverdriverdriversoftware
hardware
B A B C CB AB A
time
A BC BCA C C
CPU
CPU 2
processOS
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
http://proglit.com/
Process C
Process B
OS
Process A
0x00 00 00 00
0xFF FF FF FF
stack
heap
code0x 00 00 00 00
0x FF FF FF FF
heap
heap
RAM
byte 0
byte n
stack
heap
code0x 00 00 00 00
0x FF FF FF FF
heap
heap
RAM
byte 0
byte n
HD
http://proglit.com/
Process C
Process B
OS
Process A
jump to system call code via special instruction
RAM
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 callallocated with system call
allocated with system call
stack
code0x 00 00 00 00
0x FF FF FF FF
heap
heap
heap
deallocated with system call
stack
code0x 00 00 00 00
0x FF FF FF FF top of stack
stack boundary
heap
heap
heap
stack
code0x 00 00 00 00
0x FF FF FF FF
top of stackstack boundary
heap
heap
heap
created
waiting running
blocked
terminated
http://proglit.com/
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: D:
C:/H:/D:/
partition 2 partition 3
partition 1
C: H: D:
C:/adams/nixonH:/taylor/polk/hayesD:/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)
filespipes
socketssignals
shared memory
http://proglit.com/