proglit

65
http:// proglit.com/

Upload: neil

Post on 23-Feb-2016

89 views

Category:

Documents


0 download

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 Presentation

TRANSCRIPT

Page 1: proglit

http://proglit.com/

Page 2: proglit

hardwareand

operating systemsbasics

Page 3: proglit

BY

SA

Page 4: proglit
Page 5: proglit
Page 6: proglit
Page 7: proglit

• 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)

Page 8: proglit

RAM (Random Access Memory)

• addressable by the CPU• volatile• faster than storage• code and data of running programs

Page 9: proglit

http://proglit.com/

Page 10: proglit

programming model(simplified conception of a processor

for sake of programmers)

Page 11: proglit

instruction(a sequence of bits understood by the

processor to signal a certain action)

• copy bytes• arithmetic• bit logic• jumps

Page 12: proglit

register(a small memory area in a processor)

• status• general purpose

Page 13: proglit

ISA (Instruction Set Architecture)

x86 (IA-32, x86-64)ARMMIPSMotorola 68k

Page 14: proglit

http://proglit.com/

Page 15: proglit

call stack(local variables)program memory

heap(everything else)

code

Page 16: proglit

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

Page 17: proglit

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

Page 18: proglit

big-endian vs. little-endian(the order in which the bytes of a register are copied

from registers to memory and vice versa)

Page 19: proglit

big-endian vs. little-endian(the order in which the bytes of a register are copied

from registers to memory and vice versa)

Page 20: proglit

http://proglit.com/

Page 21: proglit

processor registersprocessor cache

random access memoryhard drives

speed, cost

capacity

Page 22: proglit

http://proglit.com/

Page 23: proglit

CPU

registers

device

read/write

Page 24: proglit

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

Page 25: proglit

ports

memory addresses

RAM

0x00 00 00 00

0xFF FF FF FF

byte 0

byte n

port 0

port n

devices

Page 26: proglit

memory addresses

RAM

0x00 00 00 00

0x00 01 00 00

0xFF FF FF FF

0x00 00 FF FF

byte 0

byte n

devices

Page 27: proglit

(code periodically checks device registers to see if the device needs the CPU to do something)

polling

Page 28: proglit

CPU

registers

deviceinterrupt line

Page 29: proglit

(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

Page 30: proglit

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

… …

Page 31: proglit

(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

Page 32: proglit

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

… …

Page 33: proglit

http://proglit.com/

Page 34: proglit

• 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

Page 35: proglit

boot firmware

CPU

registers

BIOS

Page 36: proglit

http://proglit.com/

Page 37: proglit

boot firmware

CPU

registers

BIOS

Page 38: proglit

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

Page 39: proglit

Windows(series of OS’s from Microsoft)

• Windows 7• Windows Server 2008• Windows CE

Page 40: proglit

Unix(a family of OS’s)

• Linux• BSD• OS X

Page 41: proglit

http://proglit.com/

Page 42: proglit

OS

device driver(plug-in to the OS to control a particular device)

device device device

driverdriverdriversoftware

hardware

Page 43: proglit

B A B C CB AB A

time

A BC BCA C C

CPU

CPU 2

processOS

Page 44: proglit

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

Page 45: proglit

http://proglit.com/

Page 46: proglit

Process C

Process B

OS

Process A

0x00 00 00 00

0xFF FF FF FF

Page 47: proglit

stack

heap

code0x 00 00 00 00

0x FF FF FF FF

heap

heap

RAM

byte 0

byte n

Page 48: proglit

stack

heap

code0x 00 00 00 00

0x FF FF FF FF

heap

heap

RAM

byte 0

byte n

HD

Page 49: proglit

http://proglit.com/

Page 50: proglit

Process C

Process B

OS

Process A

jump to system call code via special instruction

RAM

Page 51: proglit

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

… …

Page 52: proglit

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

Page 53: proglit

stack

code0x 00 00 00 00

0x FF FF FF FF

heap

heap

heap

deallocated with system call

Page 54: proglit

stack

code0x 00 00 00 00

0x FF FF FF FF top of stack

stack boundary

heap

heap

heap

Page 55: proglit

stack

code0x 00 00 00 00

0x FF FF FF FF

top of stackstack boundary

heap

heap

heap

Page 56: proglit

created

waiting running

blocked

terminated

Page 57: proglit

http://proglit.com/

Page 58: proglit

HD

partition 1

partition 2

partition 3

HD

partition 4

flash drive

partition 5

CD-ROM

partition 6

partition 7

Page 59: proglit

file 35

file 7

file 61

file 3

directory 21

directory 86

root directory

Page 60: proglit

partition 1

C: H: D:

C:/H:/D:/

partition 2 partition 3

Page 61: proglit

partition 1

C: H: D:

C:/adams/nixonH:/taylor/polk/hayesD:/garfield

partition 2 partition 3

Page 62: proglit

partition 1

/banana / /lemon/apple

partition 2 partition 3

Page 63: proglit

partition 1

/banana / /lemon/apple

/banana/adams/nixon/taylor/polk/hayes/lemon/apple/garfield

partition 2 partition 3

Page 64: proglit

IPC (Interprocess Communication)

filespipes

socketssignals

shared memory

Page 65: proglit

http://proglit.com/