Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 423 - Fall 2011 CS 423 – Operating Systems Design Lecture 2 – Concepts Review Klara Nahrstedt Fall 2011.

Similar presentations


Presentation on theme: "CS 423 - Fall 2011 CS 423 – Operating Systems Design Lecture 2 – Concepts Review Klara Nahrstedt Fall 2011."— Presentation transcript:

1 CS 423 - Fall 2011 CS 423 – Operating Systems Design Lecture 2 – Concepts Review Klara Nahrstedt Fall 2011

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

3 CS 423 - Fall 2011 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

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

5 CS 423 - Fall 2011 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

6 CS 423 - Fall 2011 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.

7 CS 423 - Fall 2011 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)

8 CS 423 - Fall 2011 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

9 CS 423 - Fall 2011 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?

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

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

12 CS 423 - Fall 2011 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

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

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

15 CS 423 - Fall 2011 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

16 CS 423 - Fall 2011 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)

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

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

19 CS 423 - Fall 2011 File System 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? User 1User n... File system services File...

20 CS 423 - Fall 2011 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 OS sector 1 OS sector 2 OS sector n...... Boot loader

21 CS 423 - Fall 2011 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

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

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

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

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

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

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

28 CS 423 - Fall 2011 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); }

29 CS 423 - Fall 2011 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)

30 CS 423 - Fall 2011 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

31 CS 423 - Fall 2011 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

32 CS 423 - Fall 2011 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?


Download ppt "CS 423 - Fall 2011 CS 423 – Operating Systems Design Lecture 2 – Concepts Review Klara Nahrstedt Fall 2011."

Similar presentations


Ads by Google