ch2OS.pdf
Document Details
Uploaded by Deleted User
Tags
Related
- Lecture 2- Chapter 2_Operating System Structures_32d5a35a5fee92dbb78fb8526970742c.pdf
- Operating System Structures PDF
- EEE3535 Operating Systems Notes (PDF)
- Module 2 Lesson 2 - System Calls & Programs PDF
- Operating System Fundamentals: Operating Systems Structures PDF
- Chapter 2: Operating-System Structures PDF
Full Transcript
Chapter 2: Operating-System Structures Operating System Concepts Silberschatz, Galvin and Gagne Chapter 2: Operating-System Structures Operating System Services System Calls System Programs Operating System St...
Chapter 2: Operating-System Structures Operating System Concepts Silberschatz, Galvin and Gagne Chapter 2: Operating-System Structures Operating System Services System Calls System Programs Operating System Structures Operating System Concepts 1.21 Silberschatz, Galvin and Gagne Operating System Services Operating systems provide an environment for execution of programs and services to programs and users Operating-system services for the user: User interface - Almost all operating systems have a user interface (UI). Command-Line (CLI), Graphics User Interface (GUI), Batch 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) I/O operations - A running program may require I/O, which may involve a file or an I/O device File-system manipulation - Programs need to read and write files and directories, create and delete them, search them, list file Information, permission management. Communications – Processes may exchange information, on the same computer or between computers over a network Error detection – OS needs to be constantly aware of possible errors May occur in CPU, memory, hardware, I/O devices, user program Operating System Concepts 1.22 Silberschatz, Galvin and Gagne Operating System Services (Cont.) OS services for the system itself: Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them Many types of resources - CPU cycles, main memory, file storage, I/O devices. Accounting - To keep track of which users use how much and what kinds of computer resources 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 Operating System Concepts 1.23 Silberschatz, Galvin and Gagne A View of Operating System Services Operating System Concepts 1.24 Silberschatz, Galvin and Gagne System Calls Programming interface to the services provided by the OS Typically written in a high-level language (C or C++) Mostly accessed by programs via a high-level Application Programming Interface (API) rather than direct system call use Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) Note that the system-call names used throughout this text are generic Operating System Concepts 1.25 Silberschatz, Galvin and Gagne Example of System Calls System call sequence to copy the contents of one file to another file Operating System Concepts 1.26 Silberschatz, Galvin and Gagne Application Programming Interfaces (APIs) An application program interface (API) is code that allows two software programs to communicate with each other. An API defines the correct way for a developer to request services from an operating system or other application and expose data within different contexts and across multiple channels. Operating System APIs are a key enabler to target independent software and seamless upgrading from the software perspective when the underlying hardware is changed. This is one of the significant cost reduction mechanisms promised by the use of open systems. There are four principal types of API commonly used in web-based applications: public, partner, private and composite. In this context, the API “type” indicates the intended scope of use. Operating System Concepts 1.27 Silberschatz, Galvin and Gagne Types of System Calls Process control create process, terminate process end, abort load, execute get process attributes, set process attributes wait for time wait event, signal event allocate and free memory Dump memory if error Debugger for determining bugs, single step execution Locks for managing access to shared data between processes Operating System Concepts 1.28 Silberschatz, Galvin and Gagne Types of System Calls File management create file, delete file open, close file read, write, reposition get and set file attributes Device management request device, release device read, write, reposition get device attributes, set device attributes logically attach or detach devices Information maintenance get time or date, set time or date get system data, set system data get and set process, file, or device attributes Operating System Concepts 1.29 Silberschatz, Galvin and Gagne Types of System Calls (Cont.) Communications create, delete communication connection send, receive messages if message passing model to host name or process name From client to server Shared-memory model create and gain access to memory regions attach and detach remote devices Protection Control access to resources Operating System Concepts 1.30 Silberschatz, Galvin and Gagne Examples of Windows and Unix System Calls Operating System Concepts 1.31 Silberschatz, Galvin and Gagne System Programs System programs provide a convenient environment for program development and execution. They can be divided into: File manipulation Status information sometimes stored in a File modification Programming language support Program loading and execution Communications Background services Application programs Most users’view of the operation system is defined by system programs, not the actual system calls Operating System Concepts 1.32 Silberschatz, Galvin and Gagne Operating System Structure General-purpose OS is very large program Various ways to structure ones 1. Simple structure – MS-DOS 2. More complex -- UNIX 3. Layered – an abstrcation 4. Microkernel -Mach Operating System Concepts 1.33 Silberschatz, Galvin and Gagne 1. Simple Structure -- MS-DOS MS-DOS – written to provide the most functionality in the least space Not divided into modules Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated Operating System Concepts 1.34 Silberschatz, Galvin and Gagne 2. Non-Simple Structure -- UNIX UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts Systems programs 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 1.35 Silberschatz, Galvin and Gagne Traditional UNIX System Structure Beyond simple but not fully layered Operating System Concepts 1.36 Silberschatz, Galvin and Gagne 3. Layered Approach 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. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers Operating System Concepts 1.37 Silberschatz, Galvin and Gagne 4. Microkernel System Structure Moves as much from the kernel into user space Mach example of microkernel Mac OS X kernel (Darwin) partly based on Mach Communication takes place between user modules using message passing Benefits: Easier to extend a microkernel Easier to port the operating system to new architectures More reliable (less code is running in kernel mode) More secure Detriments: Performance overhead of user space to kernel space communication Operating System Concepts 1.38 Silberschatz, Galvin and Gagne Microkernel System Structure Application File Device user Program System Driver mode messages messages Interprocess memory CPU kernel Communication managment scheduling mode microkernel hardware Operating System Concepts 1.39 Silberschatz, Galvin and Gagne 5. Modular Approach Many modern operating systems implement loadable kernel modules Uses object-oriented approach Each core component is separate Each talks to the others over known interfaces Each is loadable as needed within the kernel Overall, similar to layers but with more flexible Linux, Solaris, etc Operating System Concepts 1.40 Silberschatz, Galvin and Gagne Solaris Modular Approach Operating System Concepts 1.41 Silberschatz, Galvin and Gagne 6. Hybrid Systems Most modern OS are actually not one pure model Hybrid combines multiple approaches to address performance, security, usability needs Linux and Solaris kernels in kernel address space, so monolithic, plus modular for dynamic loading of functionality Windows mostly monolithic, plus microkernel for different subsystem personalities Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment Below (next slide) is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions) Operating System Concepts 1.42 Silberschatz, Galvin and Gagne Mac OS X Structure graphical user interface Aqua application environments and services Java Cocoa Quicktime BSD kernel environment BSD Mach I/O kit kernel extensions Operating System Concepts 1.43 Silberschatz, Galvin and Gagne Handheld - iOS Apple mobile OS for iPhone, iPad Structured on Mac OS X, added functionality Does not run OS X applications natively Also runs on different CPU architecture (ARM vs. Intel) Cocoa Touch Objective-C API for developing apps Media services layer for graphics, audio, video Core services provides cloud computing, databases Core operating system, based on Mac OS X kernel Operating System Concepts 1.44 Silberschatz, Galvin and Gagne Handheld - Android Developed by Open Handset Alliance (mostly Google) Open Source Similar stack to IOS Based on Linux kernel but modified Provides process, memory, device-driver management Adds power management Runtime environment includes core set of libraries and Dalvik virtual machine Apps developed in Java plus Android API Java class files compiled to Java bytecode then translated to executable than runs in Dalvik VM Libraries include frameworks for web browser (webkit), database (SQLite), multimedia, smaller libc Operating System Concepts 1.45 Silberschatz, Galvin and Gagne Android Architecture Application Framework Libraries Android runtime SQLite openGL Core Libraries surface media Dalvik manager framework virtual machine webkit libc Operating System Concepts 1.46 Silberschatz, Galvin and Gagne Performance Tuning We mentioned earlier that performance tuning seeks to improve performance by removing processing bottlenecks. To identify bottlenecks, we must be able to monitor system performance. Thus, the OS must have some means of computing and displaying measures of system behavior. In a number of systems, the OS does this by producing trace listings of system behavior. All interesting events are logged with their time and important parameters and are written to a file. Later, an analysis program can process the log file to determine system performance and to identify bottlenecks and inefficiencies. These same traces can be run as input for a simulation of a suggested improved system. Traces also can help people to find errors in OS behavior. Operating System Concepts 1.47 Silberschatz, Galvin and Gagne Performance Tuning Another approach to performance tuning uses single-purpose, interactive tools that allow users and administrators to question the state of various system components to look for bottlenecks. One such tool employs the UNIX command “top” to display the resources used on the system, as well as a sorted list of the “top” resource-using processes. Other tools display the state of disk I/O, memory allocation, and network traffic. The Windows Task Manager (screenshot on next slide) is a similar tool for Windows systems. The task manager includes information for current applications as well as processes, CPU and memory usage, and networking statistics. Making OS easier to understand, debug, and tune as they run is an active area of research and implementation. A leading example of such a tool: Solaris 10 DTrace dynamic tracing facility. Operating System Concepts 1.48 Silberschatz, Galvin and Gagne Performance – Windows Task Manager Operating System Concepts 1.49 Silberschatz, Galvin and Gagne