Chapter 2 OperatingSystem Structures Modified from the text



































- Slides: 35

Chapter 2: Operating-System Structures Modified from the text book Operating System Concepts – 8 th Edition Silberschatz, Galvin and Gagne © 2009

Chapter 2: Operating-System Structures n Operating System Services & User OS Interface n System Calls n System Programs (System utilities) n Operating System Design and Implementation n Virtual Machines Operating System Concepts – 8 th Edition 2. 2 Silberschatz, Galvin and Gagne © 2009

Operating System Services n One set of operating-system services provides functions that are helpful to the user: l User interface - Almost all operating systems have a user interface (UI). 4 Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch l 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). l I/O operations - A running program may require I/O, which may involve a file or an I/O device. l File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. Operating System Concepts – 8 th Edition 2. 3 Silberschatz, Galvin and Gagne © 2009

A View of Operating System Services Operating System Concepts – 8 th Edition 2. 4 Silberschatz, Galvin and Gagne © 2009

Linux Layers Operating System Concepts – 8 th Edition 2. 5 Silberschatz, Galvin and Gagne © 2009

Transition from User to Kernel Mode Operating System Concepts – 8 th Edition 2. 6 Silberschatz, Galvin and Gagne © 2009

UI: Shell Command Interpreter Operating System Concepts – 8 th Edition 2. 7 Silberschatz, Galvin and Gagne © 2009

GUI Operating System Concepts – 8 th Edition 2. 8 Silberschatz, Galvin and Gagne © 2009

API – System Call – OS Relationship Operating System Concepts – 8 th Edition 2. 9 Silberschatz, Galvin and Gagne © 2009

Standard C Library Example n C program invoking printf() library call, which calls write() system call Operating System Concepts – 8 th Edition 2. 10 Silberschatz, Galvin and Gagne © 2009

System Calls n System calls: Programming interface to the services provided by the OS l Typically written in a high-level language (C or C++) n Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use l Three most common APIs are 4 Win 32 API for Windows, 4 POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and 4 Java API for the Java virtual machine (JVM) n Why use APIs rather than system calls? Operating System Concepts – 8 th Edition 2. 11 Silberschatz, Galvin and Gagne © 2009

System Calls n System calls: Programming interface to the services provided by the OS l Typically written in a high-level language (C or C++) n Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use l Three most common APIs are 4 Win 32 API for Windows, 4 POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and 4 Java API for the Java virtual machine (JVM) n Why use APIs rather than system calls? Portability. Simplicity. Operating System Concepts – 8 th Edition 2. 12 Silberschatz, Galvin and Gagne © 2009

Types of System Calls n Process control n File management n Device management n Information maintenance n Communications n Protection Operating System Concepts – 8 th Edition 2. 13 Silberschatz, Galvin and Gagne © 2009

Examples of Windows and Unix System Calls Operating System Concepts – 8 th Edition 2. 14 Silberschatz, Galvin and Gagne © 2009

Unix I/O Calls nfile. Handle = open(path. Name, flags) l A file handle is a small integer, valid only within a single process, to operate on the device or file l Pathname: a name in the file system. In unix, devices are put under /dev. E. g. /dev/ttya is the first serial port, /dev/sda the first SCSI drive l Flags: read only, read/write, append etc… l Mode may be added as the third argument for file permission nerror. Code = close(file. Handle) l Kernel will free the data structures associated with the device Operating System Concepts – 8 th Edition 2. 15 Silberschatz, Galvin and Gagne © 2009

Unix I/O Calls nbyte. Count = read(file. Handle, buf, count) l Read at most count bytes from the device and put them in the byte buffer buf. Bytes placed from 0 th byte. l Kernel can give the process fewer bytes, user process must check the byte. Count to see how many were actually returned. l A negative byte. Count signals an error (value is the error type) nbyte. Count = write(file. Handle, buf, count) l Write at most count bytes from the buffer buf l Actual number written returned in byte. Count l A negative byte. Count signals an error Operating System Concepts – 8 th Edition 2. 16 Silberschatz, Galvin and Gagne © 2009

System Programs/Utilities n System programs/utitilies provide a convenient environment for program development and execution. The can be divided into: l File manipulation l Status information l File modification l Programming language support l Program loading and execution l Communications l Application programs n Most users’ view of the operation system is defined by system programs, not the actual system calls Operating System Concepts – 8 th Edition 2. 17 Silberschatz, Galvin and Gagne © 2009

Linux Utility Programs (1) Categories of utility programs: • • • File and directory manipulation commands. Filters. Program development tools, such as editors and compilers. Text processing. System administration. Miscellaneous. Operating System Concepts – 8 th Edition 2. 18 Silberschatz, Galvin and Gagne © 2009

Linux Utility Programs (2) Operating System Concepts – 8 th Edition 2. 19 Silberschatz, Galvin and Gagne © 2009

Operating System Design and Implementation n Design and Implementation of OS: some approaches have proven successful n Start by defining goals and specifications l Affected by choice of hardware, type of system 4 User goals – convenient to use, easy to learn, reliable, safe, and fast 4 System goals – easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient n Important principle: separate policy and mechanism. Policy: What will be done Mechanism: How to do it l Why? Operating System Concepts – 8 th Edition 2. 20 Silberschatz, Galvin and Gagne © 2009

Operating System Design and Implementation n Design and Implementation of OS: some approaches have proven successful n Start by defining goals and specifications l Affected by choice of hardware, type of system 4 User goals – convenient to use, easy to learn, reliable, safe, and fast 4 System goals – easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient n Important principle: separate policy and mechanism. Policy: What will be done Mechanism: How to do it l Why? allows maximum flexibility Operating System Concepts – 8 th Edition 2. 21 Silberschatz, Galvin and Gagne © 2009

OS Design Principles n Separate policy (what to do) and mechanism (how to do) n Layered structure n Module n Monolithic kernel vs. Microkernel Operating System Concepts – 8 th Edition 2. 22 Silberschatz, Galvin and Gagne © 2009

Layered Approach n 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. n With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers Operating System Concepts – 8 th Edition 2. 23 Silberschatz, Galvin and Gagne © 2009

MS-DOS: Simple Layer Structure n MS-DOS – written to provide the most functionality in the least space l Not divided into modules l Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated Operating System Concepts – 8 th Edition 2. 24 Silberschatz, Galvin and Gagne © 2009

Traditional UNIX System Structure Operating System Concepts – 8 th Edition 2. 25 Silberschatz, Galvin and Gagne © 2009

Modules n Most modern operating systems implement kernel modules l Uses object-oriented approach l Each core component is separate l Each talks to the others over known interfaces l Each is loadable as needed within the kernel n Overall, similar to layers but with more flexible Operating System Concepts – 8 th Edition 2. 26 Silberschatz, Galvin and Gagne © 2009

Solaris Modular Approach Operating System Concepts – 8 th Edition 2. 27 Silberschatz, Galvin and Gagne © 2009

Monolithic Kernel vs. Microkernel Operating System Concepts – 8 th Edition 2. 28 28 Silberschatz, Galvin and Gagne © 2009

Microkernel System Structure n Moves as much from the kernel into “user” space n Communication takes place between user modules using message passing n Benefits: l Easier to extend a microkernel l Easier to port the operating system to new architectures l More reliable (less code is running in kernel mode) l More secure n Detriments: l Performance overhead of user space to kernel space communication Operating System Concepts – 8 th Edition 2. 29 Silberschatz, Galvin and Gagne © 2009

Mac OS X Structure Operating System Concepts – 8 th Edition 2. 30 Silberschatz, Galvin and Gagne © 2009

Virtual Machines n A virtual machine takes the layered approach to its logical conclusion. It treats hardware and the operating system kernel as though they were all hardware. n A virtual machine provides an interface identical to the underlying bare hardware. n The operating system host creates the illusion that a process has its own processor and (virtual memory). n Each guest provided with a (virtual) copy of underlying computer. Operating System Concepts – 8 th Edition 2. 31 Silberschatz, Galvin and Gagne © 2009

Virtual Machines (Cont. ) (a) Nonvirtual machine (b) virtual machine Operating System Concepts – 8 th Edition 2. 32 Silberschatz, Galvin and Gagne © 2009

VMware Architecture Operating System Concepts – 8 th Edition 2. 33 Silberschatz, Galvin and Gagne © 2009

The Java Virtual Machine Operating System Concepts – 8 th Edition 2. 34 Silberschatz, Galvin and Gagne © 2009

Android Operating System Concepts – 8 th Edition 2. 35 Silberschatz, Galvin and Gagne © 2009