Chapter 2 Operating System Structure (1).ppt
Document Details
Uploaded by GracefulMossAgate
Full Transcript
Chapter 2: Operating-System Structures Fall 2023 Dr. Babar Shah Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 Objectives To define system calls and various types of system calls To explain the role of system programs To discuss the various ways of structurin...
Chapter 2: Operating-System Structures Fall 2023 Dr. Babar Shah Operating System Concepts – 10th Edition Silberschatz, Galvin and Gagne ©2018 Objectives To define system calls and various types of system calls To explain the role of system programs To discuss the various ways of structuring an operating system Operating System Concepts – 10th Edition 2.2 Silberschatz, Galvin and Gagne ©2018 A View of Operating System Services Operating System Concepts – 10th Edition 2.3 Silberschatz, Galvin and Gagne ©2018 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 Thus, A system call is a mechanism that provides the interface between a process and the operating system. It is a programmatic method in which a computer program requests a service from the kernel of the OS. Note that the system-call names used throughout this text are generic Operating System Concepts – 10th Edition 2.4 Silberschatz, Galvin and Gagne ©2018 Example of System Calls e.g., if we need to write a program code to read data from one file, copy that data into another file. The first information that the program requires is the name of the two files, the input and output files. System call sequence to copy the contents of one file to another file In an interactive system, this type of program execution requires some system calls by OS. First call is to write a prompting message on the screen Second, to read from the keyboard, the characters which define the two files. Operating System Concepts – 10th Edition 2.5 Silberschatz, Galvin and Gagne ©2018 System Calls Structure of the system call As you can see in the above-given System Call example diagram. Step 1) The processes executed in the user mode till the time a system call interrupts it. Step 2) After that, the system call is executed in the kernel-mode on a priority basis. Step 3) Once system call execution is over, control returns to the user mode., Step 4) The execution of user processes resumed in Kernel mode. Operating System Concepts – 10th Edition 2.6 Silberschatz, Galvin and Gagne ©2018 System Call Implementation Typically, a number associated with each system call System-call interface maintains a table indexed according to these numbers The system call interface invokes the intended system call in OS kernel and returns status of the system call and any return values The caller need know nothing about how the system call is implemented Just needs to understand what OS will do as a result call Operating System Concepts – 10th Edition 2.7 Silberschatz, Galvin and Gagne ©2018 System Call Parameter Passing Often, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and call Three general methods used to pass parameters to the OS Simplest: pass the parameters in registers When there are more parameters than registers, parameters should be stored in a block or table, and the block/table address should be passed as a parameter to a register. This approach taken by Linux Parameters placed or pushed onto the stack by the program and popped off the stack by the operating system Operating System Concepts – 10th Edition 2.8 Silberschatz, Galvin and Gagne ©2018 Types of System Calls Five types of System Calls in OS: •Process Control •File Management •Device Management •Information Maintenance •Communications Operating System Concepts – 10th Edition 2.9 Silberschatz, Galvin and Gagne ©2018 Types of System Calls Process control This system calls perform the task of process creation, process termination, etc. Functions: create process and terminate process End and abort Load and execute get process attributes and set process attributes wait for time wait event and signal event allocate and free memory Dump memory if error Debugger for determining bugs, single step execution Operating System Concepts – 10th Edition 2.10 Silberschatz, Galvin and Gagne ©2018 Types of System Calls File management File management system calls handle file manipulation jobs like creating a file, reading, and writing, etc. Functions: create file and delete file Open and close file read, write and reposition get and set file attributes Device management Device management does the job of device manipulation like reading from device buffers, writing into device buffers, etc. Functions: request device and release device get device attributes and set device attributes logically attach / detach devices Operating System Concepts – 10th Edition 2.11 Silberschatz, Galvin and Gagne ©2018 Types of System Calls (Cont.) Information maintenance It handles information and its transfer between the OS and the user program. Functions: Get or set time and date Get and set process /device attributes Communications These types of system calls are specially used for interprocess communications. Functions: Create, delete communication connections Send and receive messages Shared-memory model create and gain access to memory regions Transfer status information Attach and detach remote devices Operating System Concepts – 10th Edition 2.12 Silberschatz, Galvin and Gagne ©2018 Types of System Calls (Cont.) Protection Functions: Control access to resources Get and set permissions Allow and deny user access Operating System Concepts – 10th Edition 2.13 Silberschatz, Galvin and Gagne ©2018 System Calls Used in OS wait( ) In some systems, a process needs to wait for another process to complete its execution. fork( ) Processes use this system call to create processes that are a copy of themselves. With the help of this system Call parent process creates a child process, and the execution of the parent process will be suspended till the child process executes. exec( ) This system call runs when an executable file in the context of an already running process that replaces the older executable file. kill( ): The kill() system call is used by OS to send a termination signal to a process that urges the process to exit. exit( ): The exit() system call is used to terminate program execution. The OS reclaims resources that were used by the process after the use of exit() system call. Operating System Concepts – 10th Edition 2.14 Silberschatz, Galvin and Gagne ©2018 Examples of Windows and Unix System Calls Operating System Concepts – 10th Edition 2.15 Silberschatz, Galvin and Gagne ©2018 System Programs System Programming can be defined as the act of building Systems Software using System Programming Languages System programs provide a convenient environment for program development and execution. They can be divided into: File Management Status information sometimes stored in a File modification Programming language support Program loading and execution Communications Background services Application programs Operating System Concepts – 10th Edition 2.16 Silberschatz, Galvin and Gagne ©2018 System Programs File management - A file is a collection of specific information stored in the memory of a computer system. File management is defined as the process to Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories Status information Some user ask the system for info - date, time, amount of available memory, disk space, number of users Others provide detailed performance, logging, and debugging information Typically, these programs format and print the output to the terminal or other output devices Operating System Concepts – 10th Edition 2.17 Silberschatz, Galvin and Gagne ©2018 System Programs (Cont.) File modification Text editors to create and modify files Special commands to search contents of files or perform transformations of the text Programming-language support - Compilers, assemblers, debuggers and interpreters sometimes provided Program loading and execution- Absolute loaders, relocatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language Communications - Provide the mechanism for creating virtual connections among processes, users, and computer systems Allow users to send messages to one another’s screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another Operating System Concepts – 10th Edition 2.18 Silberschatz, Galvin and Gagne ©2018 System Programs (Cont.) Background Services (knows as services, subsystems, daemons) Launch at boot time Some for system startup, then terminate Some from system boot to shutdown Provide facilities like disk checking, process scheduling Run in user context not kernel context Application programs Run by users Not typically considered part of OS Launched by for example command line, mouse click, etc. Operating System Concepts – 10th Edition 2.19 Silberschatz, Galvin and Gagne ©2018 Operating System Design User goals and System goals User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient Important principle to separate Policy: What to do? Mechanism: How to do it? The separation of policy from mechanism allows maximum flexibility if policy decisions are to be changed later (example – timer) Operating System Concepts – 10th Edition 2.20 Silberschatz, Galvin and Gagne ©2018 Operating System Structure General-purpose OS is very large program Various ways to structure ones Simple structure – MS-DOS Layered – an abstraction Microkernel –Mach Modules Hybrid System Operating System Concepts – 10th Edition 2.21 Silberschatz, Galvin and Gagne ©2018 Simple Structure -- MS-DOS Simple Structure operating systems do not have well defined structure and are small, simple and limited systems. The interfaces and levels of functionality are not well separated. MS-DOS is an example of such operating system. These types of operating system cause the entire system to crash if one of the user programs fails. 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 – 10th Edition 2.22 Silberschatz, Galvin and Gagne ©2018 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 Windows, UNIX are the examples of this structure. Operating System Concepts – 10th Edition 2.23 Silberschatz, Galvin and Gagne ©2018 Microkernel System Structure This structure designs the operating system by removing all non-essential components from the kernel and implementing them as system and user programs. This result in a smaller kernel called the micro-kernel. Mac example of microkernel Mac OS X kernel (Darwin) partly based on Mach 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 – 10th Edition 2.24 Silberschatz, Galvin and Gagne ©2018 Modules 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. Solaris Modular Approach Operating System Concepts – 10th Edition 2.25 Silberschatz, Galvin and Gagne ©2018 Hybrid Systems Most modern operating systems 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 is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions) Operating System Concepts – 10th Edition 2.26 Silberschatz, Galvin and Gagne ©2018 Questions ? Operating System Concepts – 10th Edition 2.27 Silberschatz, Galvin and Gagne ©2018