Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
1/25/2010 Operating Systems Overview Intro, Sys Calls, Threads, etc. Tarek Abdelzaher 1 An Operating System Performs Common Application Functions Application Software Web Server Second Life Yahoo Chat Pop Mail Operating System Read/Write Hardware Standard Output Device Control File System Communication Network 2 1 1/25/2010 OS Exports a User Interface Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface Operating System Read/Write Standard Output Device Control File System Hardware Communication Network 3 Increase Portability = Minimize Machine-Specific Code Application Software Web Server Second Life Yahoo Chat Pop Mail Standard Operating System Interface Operating System (machine independent part) Read/Write Standard Output Device Control File System Communication Machine specific part Hardware Network 4 2 1/25/2010 Increase Portability = Minimize Machine-Specific Code Application Software Second Life Yahoo Chat Pop Mail Standard Operating System Interface Operating System (machine independent part) Read/Write Standard Output Device Control File System Communication Portable Web Server Machine specific part Network Hardware 5 OS Runs on Multiple Platforms while Presenting same Interface Application Software Second Life Yahoo Chat Pop Mail Standard Operating System Interface Operating System (machine independent part) Read/Write Standard Output Device Control File System Communication Portable Web Server 6 3 1/25/2010 OS Runs on Multiple Platforms while Presenting same Interface Application Software Second Life Yahoo Chat Pop Mail Standard Operating System Interface Operating System (machine independent part) Read/Write Standard Output Device Control File System Communication Portable Web Server Machine specific part Network Hardware 7 Linux (The POSIX Standard) Application Software Second Life Yahoo Chat Pop Mail The POSIX Standard Specifies UNIX Interface Operating System (machine independent part) Read/Write Standard Output Device Control File System Communication Portable Web Server Machine specific part Hardware Network 8 4 1/25/2010 OS Goals 1) Provide an interface for applications to do common functions. 9 Software Layers: Applications call Libraries Application Libraries (e.g., stdio.h) Provided pre-compiled Defined in headers Input to linker (compiler) Invoked like functions May be “resolved” when program is loaded Portable OS Layer Machine-dependent layer 10 5 1/25/2010 Software Layers: Libraries make OS System Calls Application Libraries Portable OS Layer system calls (read, open..) All “high-level” code Machine-dependent layer 11 Software Layers: System Calls access Drivers, etc. Application Libraries Portable OS Layer Machine-dependent layer Bootstrap System initialization Interrupt and exception I/O device driver Memory management Kernel/user mode switching Processor management 12 6 1/25/2010 MP1 Familiarize yourself with installing/compiling an OS and changing its interface (System Calls) 13 Steps in Making a System Call read (fd, buffer, nbytes) 14 7 1/25/2010 Some System Calls For Process Management 15 Some System Calls For File Management 16 8 1/25/2010 Some System Calls For Directory Management 17 Some System Calls For Miscellaneous Tasks 18 9 1/25/2010 OS Goals Provide an interface for applications to do common functions. 19 OS Goals Provide an interface for applications to do common functions. Manage resources 20 10 1/25/2010 Managed Resources - CPU CPU Bus Process/thread scheduling, context switching, etc. 21 Managed Resource - Memory CPU Memory Bus Paging, swapping, virtual memory management, etc. 22 11 1/25/2010 Memory Hierarchy faster larger Make it look like it’s as large as the disk and as fast as the cache 23 Managed Resource – I/O CPU Memory I/O Devices Bus Drivers, interrupts, timers, files, etc. 24 12 1/25/2010 OS Goals Provide an interface for applications to do common functions. Manage resources 25 OS Goals Provide an interface for applications to do common functions. Manage resources Structure concurrent application execution 26 13 1/25/2010 Threads and Processes 27 Things Suitable for threading Block for potentially long waits Use many CPU cycles Respond to asynchronous events Execute functions of different importance Execute parallel code 28 14 1/25/2010 Thread Usage: Word Processor What if it is single-threaded? 29 Thread Usage: Web Server 30 15 1/25/2010 Common Multi-thread Software Architectures Manager/worker Pipeline a single thread, the manager assigns work to other threads, the workers. Typically, the manager handles all input and parcels out work to the other tasks a task is broken into a series of sub-operations, each of which is handled by a different thread. An automobile assembly line best describes this model Peer similar to the manager/worker model, but after the main thread creates other threads, it participates in the work.31 User-level Threads Advantages Fast Context Switching: User level threads are implemented using user level thread libraries, rather than system calls, hence no call to OS and no interrupts to kernel When a thread is finished running for the moment, it can call thread_yield. This instruction (a) saves the thread information in the thread table, and (b) calls the thread scheduler to pick another thread to run. The procedure that saves the local thread state and the scheduler are local procedures, hence no trap to kernel, no context switch, no memory switch, and this makes the thread scheduling very fast. Customized Scheduling 32 16 1/25/2010 Kernel-level Threads Kernel can schedule threads in addition to processes. Multiple threads of a process can run simultaneously on multiple CPUs. Synchronization more efficient than for processes (but less than for user-level threads). Kernel-level threads can make blocking I/O calls without blocking other threads of same 33 process 17