OS Structures Chapter 02 PDF
Document Details
Uploaded by Deleted User
Tags
Summary
This document is a chapter on operating system structures. It details OS services, system calls, and different implementation approaches. It provides practical examples of system calls and APIs.
Full Transcript
OS Structures Chapter 02 September 8, 2024 OS: System Structures 1 Chapter Objectives ◼ To describe the services an OS provides to users, processes, and other systems ◼ To discuss the various ways of struct...
OS Structures Chapter 02 September 8, 2024 OS: System Structures 1 Chapter Objectives ◼ To describe the services an OS provides to users, processes, and other systems ◼ To discuss the various ways of structuring an OS ◼ To explain how Oss are installed, customized and how they boot September 8, 2024 OS: System Structures 2 Chapter Outline ◼ OS Services ◼ User and OS Interface ◼ System Calls ◼ System Services ◼ Linkers and Loaders ◼ Why applications are OS specific ◼ OS Structure September 8, 2024 OS: System Structures 3 - OS Services ◼ User interface – CLI, GUI, and batch ◼ Program execution ◼ I/O operations ◼ File-system manipulation ◼ Communications ◼ Error detection ◼ Resource allocation ◼ Accounting ◼ Protection and security September 8, 2024 OS: System Structures 4 -- A View of Operating System Services September 8, 2024 OS: System Structures 5 - System Calls ◼ What are System calls ◼ System Call Implementation ◼ System Call Parameter Passing ◼ Types of System Calls September 8, 2024 OS: System Structures 6 -- What are System Calls ◼ System calls provide an interface to the services made available by an OS. ◼ Typically written in a high-level language (C or C++) ◼ Mostly accessed by programs via a high-level Application Program 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) ◼ Java API for the Java virtual machine (JVM) ◼ Why use APIs rather than system calls? September 8, 2024 OS: System Structures 7 -- System Calls and API Application program API API API SC SC SC SC SC SC SC SC SC SC = System call September 8, 2024 OS: System Structures 8 -- Examples of Windows and Unix System Calls September 8, 2024 OS: System Structures 9 -- Example of Standard API September 8, 2024 OS: System Structures 10 -- Example of System Calls ◼ System call sequence to copy the contents of one file to another file Note: that the system-call names used throughout this text are generic September 8, 2024 OS: System Structures 11 -- System Call Implementation ◼ Typically, a number is associated with each system call ◼ System-call interface maintains a table indexed according to these numbers ◼ The system call interface invokes 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 obey API and understand what OS will do as a result call ◼ Most details of OS interface hidden from programmer by API September 8, 2024 OS: System Structures 12 --- System Calls n 5 4 3 2 1 OSS1 OSS2 OSS3 OSS4 OSS5 OSSn OS services September 8, 2024 OS: System Structures 13 --- API – System Call – OS Relationship September 8, 2024 OS: System Structures 14 --- Standard C Library Example ◼ C program invoking printf() library call, which calls write() system call September 8, 2024 OS: System Structures 15 -- System Call Parameter Passing ◼ Three general methods used to pass parameters to the OS ◼ Using registers: pass the parameters in registers ◼ Using block (Table) : Parameters stored in a block in memory, and address of block is passed as a parameter in a register. This approach taken by Linux and Solaris ◼ Using stack: Parameters are placed, or pushed, onto a stack by the program and popped off the stack by the operating system ◼ Block and stack methods do not limit the number or length of parameters being passed September 8, 2024 OS: System Structures 16 --- Parameter Passing via Table September 8, 2024 OS: System Structures 17 --- Types of System Calls ◼ Process control ◼ File management ◼ Device management ◼ Information maintenance ◼ Communications ◼ Protection September 8, 2024 OS: System Structures 18 - System Services ◼ System services also known as system utilities or system programs provide a convenient environment for program development and execution. They can be divided into: ◼ File manipulation ◼ Status information ◼ File modification ◼ Programming language support ◼ Program loading and execution ◼ Communications ◼ Application programs ◼ Most users’ view of the operation system is defined by system programs, not the actual system calls September 8, 2024 OS: System Structures 19 -- System Programs, System Calls and API Application program SP API API SC SC SC SC SC SC SC SC SC SC = System call SP = System programs September 8, 2024 OS: System Structures 20 -- System Programs ◼ Provide a convenient environment for program development and execution ◼ Some of them are simply user interfaces to system calls; others are considerably more complex ◼ File management - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories ◼ Status information ◼ Some 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 ◼ Some systems implement a registry - used to store and retrieve configuration information September 8, 2024 OS: System Structures 21 -- System Programs ◼ 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 September 8, 2024 OS: System Structures 22 - Linkers and Loaders ◼ Source code compiled into object files designed to be loaded into any physical memory location – relocatable object file ◼ Linker combines these into single binary executable file, also brings in libraries ◼ Program resides on secondary storage as binary executable must be brought into memory by loader to be executed ◼ Relocation assigns final addresses to program parts and adjusts code and data in program to match those addresses ◼ Modern general-purpose systems don’t link libraries into executables ◼ Rather, dynamically linked libraries (in Windows, DLLs) are loaded as needed, shared by all that use the same version of that same library (loaded once) September 8, 2024 OS: System Structures 23 -- The Role of the Linker and Loader September 8, 2024 OS: System Structures 24 - Why Applications are OS Specific ◼ Apps compiled on one OS usually not executable on other OSs. ◼ Each OS provides its own unique system calls, own file formats, etc. ◼ Apps can be multi-OS ◼ Written in interpreted language like Python, Ruby, and interpreter available on multiple OS ◼ App written in language that includes a VM (like Java) ◼ Use standard language (like C), compile separately on each OS September 8, 2024 OS: System Structures 25 - OS Structures ◼ Monolithic ◼ Layered ◼ Micro Kernel ◼ Modular ◼ Hybrid September 8, 2024 OS: System Structures 26 -- Monolithic Structure ◼ Limited or no structure ◼ Example: 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 September 8, 2024 OS: System Structures 27 --- Monolithic Structure - Original UNIX ◼ UNIX – limited by hardware functionality, the original UNIX OS 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 September 8, 2024 OS: System Structures 28 ---- Traditional UNIX System Structure September 8, 2024 OS: System Structures 29 -- Layered Approach ◼ The OS 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 ◼ Draw backs: ◼ Careful definition of layers is needed because a layer can only use the one below it. ◼ Less efficient than the other types ◼ Example: OS/2 and the first release of NT September 8, 2024 OS: System Structures 30 -- Microkernel System Structure ◼ Moves as much from the kernel into “user” space ◼ Communication takes place between modules using message passing ◼ Benefits: ◼ Easier to extend a microkernel ◼ Easier to port the OS to new architectures ◼ More reliable (less code is running in kernel mode) ◼ More secure ◼ Detriments: Performance overhead of user space to kernel space communication ◼ Example: Mach September 8, 2024 OS: System Structures 31 --- Microkernel OS Architecture September 8, 2024 OS: System Structures 32 -- Modular ◼ Most modern Oss implement 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 September 8, 2024 OS: System Structures 33 --- Solaris Modular Approach September 8, 2024 OS: System Structures 34 -- Hybrid Systems ◼ Most modern OSs are not one pure model ◼ Hybrid combines multiple approaches to address performance, security, usability needs ◼ Linux and Solaris kernels are monolithic and modular for dynamic loading of functionality ◼ Windows mostly monolithic, plus microkernel for different subsystem September 8, 2024 OS: System Structures 35 - Summary … ◼ OS services: ◼ User interface – CLI, GUI, and batch ◼ Program execution ◼ I/O operations ◼ File-system manipulation ◼ Communications ◼ Error detection ◼ Resource allocation ◼ Accounting ◼ Protection and security ◼ System Calls ◼ Implementation: ◼ Typically, a number is associated with each system call. ◼ System-call interface maintains a table indexed according to these numbers ◼ API ◼ System Call Parameter Passing via: Register, block, stack ◼ Types of System Calls: process control, storage manager, I/O manager, … September 8, 2024 OS: System Structures 36 … - Summary ◼ System Programs ◼ Operating System Structure: ◼ Monolithic, ◼ layered, ◼ microkernel, ◼ modular ◼ Hybrid September 8, 2024 OS: System Structures 37 Reading List ◼ 2.1 to 2.6 and 2.8 September 8, 2024 OS: System Structures 38 Disclaimer ◼ Parts of the lecture slides contain original work of Abraham Silberschatz, Peter B. Galvin, Greg Gagne, Andrew S. Tanenbaum, and Gary Nutt. The slides are intended for the sole purpose of instruction of Operating Systems course at KFUPM. All copyrighted materials belong to their original owner(s). September 8, 2024 OS: System Structures 39 September 8, 2024 OS: System Structures 40