CSE 3320 Operating Systems Cmputer and Operating Systems Overview Jia Ra Department f Cmputer Science and Engineering http://ranger.uta.edu/~jra
Overview Recap f last class What is an perating system? Functinalities f perating systems Types f perating systems Cmputer hardware review Operating system rganizatin
Cmputer Hardware Review Basic cmpnents f a simple persnal cmputer CPU: data prcessing Memry: vlatile data strage Disk: persistent data strage NIC: inter-machine cmmunicatin Bus: intra-machine cmmunicatin
Central Prcessing Unit (CPU) Cmpnents Arithmetic Lgic Unit (ALU) Cntrl Unit (CU) Clck rate The speed at which a CPU is running Data strage General-purpse registers: EAX, EBX Special-purpse registers: PC (EIP), SP, IR Parallelism Instructin-level parallelism Thread-level parallelism } Hyper-threading: duplicate units that stre architectural states } Replicated: registers. Partitined: ROB, lad buffer Shared: reservatin statin, caches
Multi-Cre Prcessrs Multiple CPUs n a single chip Scket C Cache FSB DRAM Cntrller Memry Nn-unifrm perfrmance A schematic view f Intel Cre 2
Multi-Cre Prcessrs: NUMA Lcal memry Intel Cre i7 Cre Memry Subsystem UnCre Memry Subsystem Shared LLC
Memry A typical memry hierarchy
Why Cache is imprtant? A larger size than registers A much faster speed than memry Cncurrent accesses t memry when cache misses ccur
Mre n CPU Cache Cache management When t put a new item int the cache. Which cache line t put the new item in. Which item t remve frm the cache when a slt is needed. Where t put a newly evicted item in the larger memry. When t write dirty item back t memry
Hard Disks Track Disk heads mve tgether Sectr A stack f platters, a surface with a magnetic cating Typical numbers (depending n the disk size): 500 t 2,000 tracks per surface 32 t 128 sectrs per track } A sectr is the smallest unit that can be read r written Originally, all tracks have the same number f sectrs: Cnstant bit density: recrd mre sectrs n the uter tracks
Magnetic Disk Characteristics Disk head: each side f a platter has separate disk head Read/write data is a three-stage prcess: Seek time: psitin the arm ver the prper track Rtatinal latency: wait fr the desired sectr t rtate under the read/write head Transfer time: transfer a blck f bits (sectr) under the read-write head Average seek time as reprted by the industry: Typically in the range f 8 ms t 15 ms (Sum f the time fr all pssible seek) / (ttal # f pssible seeks) Due t lcality f disk reference Lng seek time Only ne request at a time Thrughput is dependent n data size Actual average seek time may nly be 25% t 33% f the advertised number
CPU v.s. Hard Disks Similarity Time-sharing Differences (executin vehicle v.s. strage device) CPU } Cache reuse -> tempral lcality } Easy t switch between sharing parties -> fine grain, verhead sensitive } Usually multiple CPUs-> lad balancing } Multiple executin mdes -> energy saving Hard disks } Almst n data reuse, but faster t read adjacent data -> spatial lcality } Expensive t switch between sharing parties -> carse grain } Striping r replicatin required if using multiple disks -> crdinatin
Memry Management Multiprgramming Hw t prtect the prgrams frm ne anther and the kernel frm them all? Hw t handle relcatin? Virtual memry space/address à Physical memry space/address
I/O Devices Device cntrller T prvide a simple interface f device cntrl t OS Device driver The sftware that talks t a cntrller, giving it cmmands and accepting respnses OS Device driver registers Device cntrller
Interactins between OS and I/O Devices The OS gives cmmands t the I/O devices The I/O device ntifies the OS when the I/O device has cmpleted an peratin r has encuntered an errr Data is transferred between memry and an I/O device
Hw I/O Devices Ntify the OS? Plling The I/O device put infrmatin in a status register The OS peridically check the status register Interrupt Whenever an I/O device needs attentin frm the prcessr, it interrupts the prcessr frm what it is currently ding DMA Delegate I/O respnsibility frm CPU
Interrupts Interrupts An interruptin f the nrmal sequence f executin Imprves prcessing efficiency Allws the prcessr t execute ther instructins while an I/O peratin is in prgress A suspensin f a prcess caused by an event external t that prcess and perfrmed in such a way that the prcess can be resumed Types f interrupts I/O Prgram (exceptin) } arithmetic verflw } divisin by zer } reference utside user s memry space Timer, Hardware failure
I/O Interrupt (a) 1. CPU writes cmds in t device registers 2. The device signals interrupt cntrller 3. Interrupt cntrller infrms a CPU 4. The CPU accepts the interrupt and triggers the service rutine (b)
System Calls What is the key difference between interrupts and traps (system calls)? prgram-triggered vs. event-triggered synchrnus vs. asynchrnus There are 11 steps in making the system call read (fd, buffer, nbytes)
Operating System Cmpnents Prcess management Memry management File and strage Netwrking
Prcess Management Prcess: a fundamental OS cncept Memry address space Sme set f registers Prtectin dmain Resurce allcatin unit OS respnsibilities fr prcess management Prcess creatin and deletin Prcess scheduling, suspensin, and resumptin Inter-prcess cmmunicatin and synchrnizatin
Memry Management Memry A large array f addressable wrds and bytes OS respnsibilities fr memry management Allcate and de-allcate memry space Keep memry space efficiently utilized Keep track f which part f memry are used and by whm Design gals: transparency and efficiency
File and Strage Management A file is a cllectin f data (usually) stred n disk with a unique name Prgrams Data Devices (UNIX & Linux) OS respnsibilities fr file management Organize directries and files Map files nt disk OS respnsibilities fr disk management Disk space management Disk scheduling
Summary Cmputer hardware Time-sharing: CPU, disk Space-sharing: memry, disk OS cmpnents Prcess management Memry management File and strage management Additinal readings and practice Sectin 1.6 and try the fllwing Linux cmmands } Wh, uname, ls, cat, cp, rm, mv, cd, mkdir, tuch, chmd } Use man t see the manual f abve cmmends Write an C prgram with an utput t the screen } Strace trace.txt./your_prog } See the system calls triggered (execve, write, ) } http://unix.stackexchange.cm/questins/797/understanding-the-linux-kernel-surce Check the VMware tutrial n curse website