1 / 32

CS 423 – Operating Systems Design Lecture 2 – Concepts Review

This lecture provides an overview of operating system concepts, including administrative issues, memory management, CPU management, and I/O device management.

choyt
Download Presentation

CS 423 – Operating Systems Design Lecture 2 – Concepts Review

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS 423 – Operating Systems DesignLecture 2 – Concepts Review Klara Nahrstedt Fall 2011 CS 423 - Fall 2011

  2. Overview • Administrative Issues • System Concepts Review (cs231, cs232, cs241) • Read Tanenbaum textbook • Chapter Sections: 1.4-1.6 CS 423 - Fall 2011

  3. Administrative Issues • MPs • Find MP partner (s) and submit form from compass about the groups today 8/24 • MP1 will be posted on Monday 8/29 (not graded, but very strongly recommended) • Proficiency Exam • Student will do MP4 and final exam • Student needs to get VMware server account and should contact TAs to arrange for the environment ahead of MP4 posting time • Review cs231/232/241 concepts CS 423 - Fall 2011

  4. Typical Computer System Memory CPU Programs and data . . . Operating System Software CPU OS Network Apps Data CS 423 - Fall 2011

  5. OS Major Components • Resource management • CPU • Process and Thread Management • Memory • Memory Management • Device • I/O Management (Disk, Network, Camera, Microphone, Timers, Power) • File system • Bootstrapping CS 423 - Fall 2011

  6. Processors • Each CPU has a specific set of instructions • All CPUs contain • General registers inside to hold key variables and temporary results • Special registers visible to the programmer • Program counter contains the memory address of the next instruction to be fetched • Stack pointer points to the top of the current stack in memory • PSW (Program Status Word) contains the condition code bits which are set by comparison instructions, the CPU priority, the mode (user or kernel) and various other control bits. CS 423 - Fall 2011

  7. How Processors Work • Execute instructions • CPU cycles • Fetch (from mem)  decode  execute • Program counter (PC) • When is PC changed? • Pipeline: fetch n+2 while decode n+1 while execute n • Two modes of CPU (why?) • User mode (a subset of instructions) • Privileged mode (all instruction) • Trap (special instruction) CS 423 - Fall 2011

  8. Processor (CPU) Management • Goals • Time sharing • Multiple CPU allocations • Issues • Do not waste CPU resources • Synchronization and mutual exclusion • Fairness • Deadlock free Analogy: Video Games CS 423 - Fall 2011

  9. Memory Access • Memory read: • Assert address on address lines • Wait till data appear on data line • Much slower than CPU! • How many memory access for one instruction? • Fetch instruction • Fetch operand (0, 1 or 2) • Write results (0 or 1) • How to speed up instruction execution? CS 423 - Fall 2011

  10. CPU Cache • Cache hit: • no need to access memory • Cache miss: • data obtained from memory, possibly update cache CS 423 - Fall 2011

  11. Registers < 1KB capacity 1 nsec access time Cache 4 MB capacity 2 nsec access time Main Memory 512-2048 MB 10 nsec access time Magnetic Disk 200-1000 GB 10 msec access time Magnetic Tape 400-800 GB 100 sec access time Source: http://en.wikipedia.org/wiki/Computer_data_storage#Primary_storage

  12. Memory Management • How to protect programs from each other? • How to handle relocation ? • Base register • Limit register • Check and Mapping of Addresses • Virtual Address - Physical Address • Memory Management Unit (MMU – located on CPU chip or close to it • Performance effects on memory system • Cache • Context switch CS 423 - Fall 2011

  13. Memory Management • Goals • Support programs to run • Allocation and management • Transfers from and to secondary storage • Issues • Efficiency & convenience • Fairness • Protection Register L2 10x Memory 200x Disk 10Mx Tape 100Mx CS 423 - Fall 2011

  14. I/O Device Management User 1 User n • Goals • Interactions between devices and applications • Ability to plug in new devices • Issues • Efficiency • Fairness • Protection and sharing . . . Library support Driver Driver I/O device I/O device . . . CS 423 - Fall 2011

  15. I/O Devices • Controller • Example: Disk Controller • Controllers are complex converting OS request into device parameters • Controllers often contain small embedded computers • Device • Fairly simple interfaces and standardized • IDE (Integrated Drive Electronics) – standard disk type on Pentiums and other computers CS 423 - Fall 2011

  16. I/O Devices • Device Driver • Needed since each type of controller may be different. • Software that talks to a controller, giving it comments and accepting responses • Each controller manufacturer supplies a driver for each OS it supports (e.g., drivers for Windows 7, UNIX) CS 423 - Fall 2011

  17. Methods for I/O • How device driver talks to controller • Busy wait • Interrupt • DMA CS 423 - Fall 2011

  18. File System Example File system for a university department CS 423 - Fall 2011

  19. File System User 1 User n • A typical file system • Open a file with authentication • Read/write data in files • Close a file • Can the services be moved to user level? . . . File system services File File . . . CS 423 - Fall 2011

  20. Bootstrapping • Power up a computer • Processor reset • Set to known state • Jump to ROM code • Load in the boot loader from stable storage • Jump to the boot loader • Load the rest of the operating system • Initialize and run Boot loader Boot loader OS sector 1 OS sector 2 . . . OS sector n CS 423 - Fall 2011

  21. From Lecture 1: What is OS • Code that: • Sits between programs & hardware • Sits between different programs • Sits betweens different users • Job of OS: • Manage hardware resources • Allocation, protection, reclamation, virtualization • Provide services to app. How? -- System Call • Abstraction, simplification, standardization Application OS Hardware CS 423 - Fall 2011

  22. A peek into Unix/Linux Application Libraries User space/level Kernel space/level Portable OS Layer Machine-dependent layer • User/kernel modes are supported by hardware • Some systems do not have clear user-kernel boundary CS 423 - Fall 2011

  23. Unix: Application Application (E.g., emacs) • Written by programmer • Compiled by programmer • Uses function calls Libraries Portable OS Layer Machine-dependent layer CS 423 - Fall 2011

  24. Unix: Libraries Application • Provided pre-compiled • Defined in headers • Input to linker (compiler) • Invoked like functions • May be “resolved” when program is loaded Libraries (e.g., stdio.h) Portable OS Layer Machine-dependent layer CS 423 - Fall 2011

  25. Typical Unix OS Structure Application Libraries Portable OS Layer Machine-dependent layer • system calls (read, open..) • All “high-level” code CS 423 - Fall 2011

  26. Typical Unix OS Structure Application • Bootstrap • System initialization • Interrupt and exception • I/O device driver • Memory management • Kernel/user mode switching • Processor management Libraries Portable OS Layer Machine-dependent layer CS 423 - Fall 2011

  27. Steps in Making a System Call Example: read (fd, buffer,nbytes) CS 423 - Fall 2011

  28. System Calls (POSIX) • System calls for process management • Example of fork used in simplified shell program #define TRUE 1 while(TRUE) { type_prompt(); read_command(command, parameters); if (fork()!=0) { /* some code*/ waitpid(-1,&status, 0);} else { /* some code*/ execve(command, parameters,0); } } CS 423 - Fall 2011

  29. System Calls (POSIX) • System calls for file/directory management • fd=open(file,how,….) • n=wride(fd,buffer,nbytes) • s=rmdir(name) • Miscellaneous • s=kill(pid,signal) • s=chmod(name,mode) CS 423 - Fall 2011

  30. System Calls (Windows Win32 API) • Process Management • CreateProcess- new process (combined work of fork and execve in UNIX) • In Windows – no process hierarchy, event concept implemented • WaitForSingleObject – wait for an event (can wait for process to exit) • File Management • CreateFile, CloseHandle, CreateDirectory, … • Windows does not have signals, links to files, …, but has a large number of system calls for managing GUI CS 423 - Fall 2011

  31. OS Service Examples • Services that need to be provided at kernel level • System calls: file open, close, read and write • Control the CPU so that users won’t stuck by running while ( 1 ) ; • Protection: • Keep user programs from crashing OS • Keep user programs from crashing each other • Services that can be provided at user level • Read time of the day CS 423 - Fall 2011

  32. You Live in Interesting Times… • Processors speed used to double in 18 months (Moore’s Law), but we are reaching the upper bound (due to thermal problems) and need to go towards multi-core processors, i.e., parallelism to increase the processing power • Disk doubling every 12 months • Global bandwidth every 6 month • What will the future OS be? CS 423 - Fall 2011

More Related