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
Operating System Architectures OS as virtual machine to users Mechanisms and Policies Mechanisms Policies How basic facilities should be What specifics to be done (flexibility) Time construct for CPU protection How long the timer for a user? No change over place and time Change (only redefine param.) Giving priority Priority values (I/O/CPU bound) Two Key Architectures: Monolithic/Microkernels Monolithic massive, undifferentiated, intractable Microkernel only basic abstractions (mechanism) (addr map, drivers, ipc, interrupts, switch) single addr. space, efficiency secure extensibility, emulation (VM), lack of structure-> layering, OO modularity, open distri. System Unix, Windows (XP) Mach, Chorus [Note: XP embodys basic OO mechanism with access-interface defined] Hybrid Approaches Mach and Chorus (microkernel) improved version Initially developed by running servers as user processes which communicate with kernel via interrupts/messages Performance considerations: servers can be loaded dynamically into kernel or user address space, client interactions via same ipc calls. Can debug a server at user level, and then later run it inside the kernel address for performance (but then may threatens integrity – if still has bugs) SPIN (’95): Trade the efficiency for protection by employing type-safe language (modula-3) for protection. Kernel and dynamically loaded modules grafted on to kernel (single address space) Using type-safe language for mutual protection (access only given by a reference) Minimize dependencies between system modules by choosing an event-based (network, timer, page fault) model for interactions between modules System components register themselves for handlers for events L4 2nd generation microkernel design Forces dynamically loaded system modules executed in user space (but optimize IPC to offset the costs) Offloads kernel complexity: management of address space in user-level servers Exokernel Employing user-level libraries (instead of user-level servers) to supply function extensions Only protected allocation of extremely low-level resources such as disk blocks. Expects all other resource management functionality (even file system) to be linked in to applications as libraries. Dynamically loadable kernel modules Disadvantages: (1) Size: module management using kernel memory space (2) Complexity of kernel bootstrap Modules loaded from disk (driver needed to access disk must be loaded first) Manage bootstrap requiring extra work Choices: (1) How often: modules (drivers) to be used – on demand? (2) Kernel to be built on large varieties of machines or single machine? kernel symbols (only fixed set of entry points available): (1) Ensure that the kernel module can not invoke arbitrary code with kernel and interfere with kernel execution (2) Guaranteed that the kernel interactions at controlled points Limited number of symbols can be accessed to kernel module: Loss of flexibility and performance because some details of kernel are hidden from the module Shared Libraries: advantages Reliability: Protection to prevent bug in kernel Performance: Less kernel memory Calling faster – since calling kernel involves system call Manageability Loaded as needed, upgrade is easy- no system down Shared Libraries: drawbacks Some code unsuitable in shared library Low level dev drivers or file systems Services shared around the entire system better implemented in kernel if performance critical. Otherwise: if it is running as separate process/communicating with it through IPC (requiring two context switches for each requested) Security/Privilege Limitation Shared lib. runs with privilege of process calling the lib Can not directly access resources inaccessible to calling process Service provided requires any privilege outside a normal process or data managed by library needs to be protected from normal user process - ? Virtual Machines Layered approach to its logical conclusion Treats HW and OS kernel as though they are all hardware Provides interface identical to underlying bare hardware Complete protection of system resources (isolated) – OS development OS, VMWare, JVM .NET Framework Process and Interprocess Communication Process Representation: Process Control Block (PCB) Example: Unix proc and user struct, Linux task_struct Threads: User level and Kernel level Many-to-One, One-to-One, Hybrid Model (LWP) Examples: POSIX threads, Java threads, Windows threads, Linux Threads Two fundamental models of Interprocess Communications Shared Memory Speed, shared-memory region Message Passing Inter-machine, system calls, slower, kernel intervention Examples of IPC Systems POSIX API for shared memory Message Passing in Mach OS, client-server systems Windows XP using shared memory for providing message passing POSIX Shared Memory segment_id = shmget (IPC_PRIVAT, size, S_IRUSR | S_IWUSR); shared_memory = (char *) shmat (id, NULL, 0); [sprintf (shared_memory, “contents to shared memory”);] shmdt(shared_memory); shmctl (segment_id, IPC_RMID, NULL); Windows XP message passing using shared-memory Local procedure cal (LPC) Port object to maintain connection between two processes (connection port for client’s open, and communication ports) Pass (a larger) message through a section object (set up a region of shared-memory) Process Scheduling Real-Time and Time-Sharing System Soft Real-time (with high priorities) Hard Real-Time (guaranteed with redundancy) Time-Sharing Priorities values dynamically changed Priority Scheduling, Multilevel Feedback Queues Aging (priority degradation) I/O completion (priority boost) CPU bound vs. I/O bound (favored) Examples: Solaris 2 scheduling Table driven with priority changed: quantum expired and wakeup after sleep Windows XP Scheduling Aging (quantum) and priority boosting based on I/O events Process Synchronization and Deadlocks Critical-Section Problem and Locks Locks Hardware instruction support (Test-and-Set, Compare-and-Swap) mutex_locks spin_locks Implementations of mutx/spin locks using test-and-set instruction Semaphores Shared variables, P and V operations, and wait quesues Binary semaphores Counting semaphores Producer/Consumer Problem Semaphore solutions (Silberschatz OSC : Slides 6.22-24) Readers and Writers problem Semaphore solution (Silberschatz OSC: Slides 6.25-27) Binary semaphore Solution of favoring readers Favor writers (Writer pending solution) Synchronization Examples Solaris operating system Spinlocks (short duration) Adaptive mutex (spin if lock owner is running) Semaphores, Conditional Variables (cv_wait, cv_signal) Reader/Writer Locks Turnstile (sleep queue) Priority inversion and priority inheritance protocol Synchronization in Windows XP Spinlocks/Queued Spinlocks (Kernel) Dispatcher objects (Executive): mutex, semaphores, events, etc. POSIX Pthreads Synchronization Primitives Mutex locks: pthread_mutex_init/lock/unlock Condition Variables: pthread_cond_init/signal/wait Read-Write Locks: pthread_rwlock_init/rdlock/wrlock DeadLocks Four Necessary conditions (mutex, hold-wait, preemption, circle-wait) Detection and recovery (cycle, kill/abort) Prevention: violate any of the necessary conditions Avoidance: safe state, Banker’s algorithm Virtual Memory Implementation Segmentation and paging MULTICS (Silberschatz OSC – Slide 8.52) Intel Pentium (Silberschatz OSC – Slide 8.54) Design Issues for paging Systems Working Set Model, Pre-paging TLB Reach (Translation Look-aside Buffer) Replacement Algorithms (LRU, Second-Chance, Clock) Program Structure (Silberschatz OSC: Slide 9.63) Local versus Global Allocation Policies Page Size Selection (table space, internal fragmentation. I/O) Operating System Examples Windows XP clustering, working-set trimming Solaris Clock algorithm Parameters and Scan Rate: lotsfree, desfree, minfree (swap) File-System Design and Implementation Virtual File Systems (Layered File System) In-Memory File System Structure (Silberscharz: Slide 11.8) Open and Read Design Criteria of Allocation Methods Contiguous Allocation Simple, Random Access, Fragmentation, Files can not grow Linked Allocation (FAT, Silberschatz OSC: Slide 11.20) Simple, No Random Access, No Fragmentation Indexed Allocation Random Access, No Fragmentation, Extra space form index table Combined Scheme (Unix, Silberschatz OSC: Slide 11.27) Performance File is usually accessed sequentially and file is small ? Contiguous File is usually accessed sequentially and file is large? Linked File is usually accessed randomly and file is large? Indexed Implementation of Free-Space management Bit Vector Extra space for bit maps, easy to get contiguous file Protect bit map on disk Access in memory – Consistency Problem Linked List No waste of space, can not get contiguous space easily Protect pointer to free list Efficiency and Performance of File-system Design Efficiency Issues (disk space) Disk allocation and directory algorithms Types of data kept in file’s directory entry Performance Issues Even after the basic file-system algorithms have been selected, We can still improve performance in several ways: Disk Cache (memory for frequently used blocks) Free-behind and Read-ahead to optimize sequential access Memory as virtual disk or RAM disk