Chapter 2: Operating-System Structures Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013 Chapter 2: Operating-System Structures s Operating System Services s User Operating System Interface s System Calls s Types of System Calls s System Programs s Operating System Design and Implementation s Operating System Structure Operating System Concepts – 9th Edition 2.2 Silberschatz, Galvin and Gagne ©2013 Objectives s To describe the services an operating system provides to users, processes, and other systems s To discuss the various ways of structuring an operating system s To explain how operating systems are installed and customized and how they boot Operating System Concepts – 9th Edition 2.3 Silberschatz, Galvin and Gagne ©2013 Operating System Services s Operating systems provide an environment for execution of programs and services to programs and users s One set of operating-system services provides functions that are helpful to the user: q User interface - Almost all operating systems have a user interface (UI) Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch q Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error) Operating System Concepts – 9th Edition 2.4 Silberschatz, Galvin and Gagne ©2013 q I/O operations - A running program may require I/O, which may involve a file or an I/O device q File-system manipulation - The file system is of particular interest Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management q Communications – Processes may exchange information, on the same computer or between computers over a network Communications may be via shared memory or through message passing (packets moved by the OS) Operating System Concepts – 9th Edition 2.5 Silberschatz, Galvin and Gagne ©2013 q Error detection – OS needs to be constantly aware of possible errors May occur in the CPU and memory hardware, in I/O devices, in user program For each type of error, OS should take the appropriate action to ensure correct and consistent computing Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system Operating System Concepts – 9th Edition 2.6 Silberschatz, Galvin and Gagne ©2013 Operating System Services (Cont.) s Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing q Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them Many types of resources - Some (such as CPU cycles, main memory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code q Accounting - To keep track of which users use how much and what kinds of computer resources Operating System Concepts – 9th Edition 2.7 Silberschatz, Galvin and Gagne ©2013 q Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other Protection involves ensuring that all access to system resources is controlled Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts If a system is to be protected and secure, precautions must be instituted throughout it A chain is only as strong as its weakest link Operating System Concepts – 9th Edition 2.8 Silberschatz, Galvin and Gagne ©2013 A View of Operating System Services Operating System Concepts – 9th Edition 2.9 Silberschatz, Galvin and Gagne ©2013 User Operating System Interface - CLI s CLI or command interpreter allows direct command entry q Sometimes implemented in kernel, sometimes by systems program (Windows, Unix) q Sometimes multiple flavors implemented – shells q Primarily fetches a command from user and executes it Sometimes commands built-in, sometimes just names of programs – If the latter, adding new features doesn’t require shell modification Operating System Concepts – 9th Edition 2.10 Silberschatz, Galvin and Gagne ©2013 Operating System Structure s General-purpose OS is very large program s Various ways to structure one as follows Operating System Concepts – 9th Edition 2.31 Silberschatz, Galvin and Gagne ©2013 Simple Structure s I.e MS-DOS – written to provide the most functionality in the least space q Not divided into modules q Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated Operating System Concepts – 9th Edition 2.32 Silberschatz, Galvin and Gagne ©2013 UNIX s UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring The UNIX OS consists of two separable parts q Systems programs q The kernel Consists of everything below the system-call interface and above the physical hardware Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level Operating System Concepts – 9th Edition 2.33 Silberschatz, Galvin and Gagne ©2013 Traditional UNIX System Structure Beyond simple but not fully layered Operating System Concepts – 9th Edition 2.34 Silberschatz, Galvin and Gagne ©2013 Layered Approach s The operating system is divided into a number of layers (levels), each built on top of lower layers The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface s With modularity, layers are selected such that each uses functions (operations) and services of only lowerlevel layers Operating System Concepts – 9th Edition 2.35 Silberschatz, Galvin and Gagne ©2013 Microkernel System Structure s Moves as much from the kernel into user space s Mach example of microkernel q Mac OS X kernel (Darwin) partly based on Mach s Communication takes place between user modules using message passing s Benefits: q Easier to extend a microkernel q Easier to port the operating system to new architectures q More reliable (less code is running in kernel mode) q More secure s Detriments: q Performance overhead of user space to kernel space communication Operating System Concepts – 9th Edition 2.36 Silberschatz, Galvin and Gagne ©2013 Microkernel System Structure Application Program File System messages Interprocess Communication Device Driver user mode messages memory managment CPU scheduling kernel mode microkernel hardware Operating System Concepts – 9th Edition 2.37 Silberschatz, Galvin and Gagne ©2013 Modules s Most modern operating systems implement loadable kernel modules q Uses object-oriented approach q Each core component is separate q Each talks to the others over known interfaces q Each is loadable as needed within the kernel s Overall, similar to layers but with more flexible q Linux, Solaris, etc Operating System Concepts – 9th Edition 2.38 Silberschatz, Galvin and Gagne ©2013 Solaris Modular Approach Operating System Concepts – 9th Edition 2.39 Silberschatz, Galvin and Gagne ©2013 Hybrid Systems s Most modern operating systems actually not one pure model q Hybrid combines multiple approaches to address performance, security, usability needs q Linux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of functionality q Windows mostly monolithic, plus microkernel for different subsystem personalities s Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment q Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions) Operating System Concepts – 9th Edition 2.40 Silberschatz, Galvin and Gagne ©2013 Mac OS X Structure graphical user interface Aqua application environments and services Java Cocoa Quicktime BSD kernel environment BSD Mach I/O kit Operating System Concepts – 9th Edition kernel extensions 2.41 Silberschatz, Galvin and Gagne ©2013 iOS s Apple mobile OS for iPhone, iPad q Structured on Mac OS X, added functionality q Does not run OS X applications natively Also runs on different CPU architecture (ARM vs Intel) q Cocoa Touch Objective-C API for developing apps q Media services layer for graphics, audio, video q Core services provides cloud computing, databases q Core operating system, based on Mac OS X kernel Operating System Concepts – 9th Edition 2.42 Silberschatz, Galvin and Gagne ©2013 Android s Developed by Open Handset Alliance (mostly Google) q Open Source s Similar stack to IOS s Based on Linux kernel but modified q Provides process, memory, device-driver management q Adds power management s Runtime environment includes core set of libraries and Dalvik virtual machine q Apps developed in Java plus Android API Java class files compiled to Java bytecode then translated to executable than runs in Dalvik VM s Libraries include frameworks for web browser (webkit), database (SQLite), multimedia, smaller libc Operating System Concepts – 9th Edition 2.43 Silberschatz, Galvin and Gagne ©2013 Applications Android Architecture Application Framework Libraries Android runtime SQLite openGL surface manager media framework webkit Core Libraries Dalvik virtual machine libc Linux kernel Operating System Concepts – 9th Edition 2.44 Silberschatz, Galvin and Gagne ©2013 End of Chapter Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013