Computer System Overview Chapter 3 OS Components and

  • Slides: 22
Download presentation
Computer System Overview Chapter 3 OS Components and Services System Calls OS Structure 1

Computer System Overview Chapter 3 OS Components and Services System Calls OS Structure 1 Chapter 3

System Components To meet the difficult requirements of multiprogramming and time sharing, OS supports

System Components To meet the difficult requirements of multiprogramming and time sharing, OS supports the following types of system components: n u Process management u Memory management u File system management u Information protection and security u Scheduling and resource management 2 Chapter 3

Process Concept n A process is a program in execution u u Associated data

Process Concept n A process is a program in execution u u Associated data (variables, buffers…) Execution context: i. e. all the information that F CPU needs to execute the process • Content of the processor registers F OS needs to manage the process: • Priority of the process • Event (if any) for which the process is waiting • . . . 3 Chapter 3

A simplementation of processes n n The process index register contains the index into

A simplementation of processes n n The process index register contains the index into the process list of the currently executing process (B) A process switch from B to A consist of storing (in memory) B’s context and loading (in CPU registers) A’s context u 4 Save/Restore Chapter 3

Memory Management Main memory is central to the operation of a modern computer system

Memory Management Main memory is central to the operation of a modern computer system OS is responsible for the following memory management activities n n u Keep track of which parts memory are currently being used and by whom u Decide which process is to be loaded when memory space becomes available u Allocate and de-allocate memory space as needed 5 Chapter 3

Virtual Memory Virtual memory concept allows programs to address memory from a logical point

Virtual Memory Virtual memory concept allows programs to address memory from a logical point of view without regard to the amount that is physically available While a program is running only a portion of the program and data is kept in (real) memory Other portions are kept in blocks on disk n n n u User has access to a memory space that is larger than real memory 6 Chapter 3

Virtual Memory Management n n n All memory references made by a program are

Virtual Memory Management n n n All memory references made by a program are to virtual memory The hardware (mapper) must map virtual memory address to real memory address If a reference is made to a virtual address not in memory, then u (1) a portion of the content of real memory is swapped out to disk u (2) the desired block of data is swapped in 7 Chapter 3

File System Management Implements long-term store (often on disk) Information is stored in named

File System Management Implements long-term store (often on disk) Information is stored in named objects called files n n u. A file is an abstraction of the physical storage device u Files are usually organized into directories Files may be copied into virtual memory as required by programs n 8 Chapter 3

File System Operations File and directory creation and deletion Support of primitives to manipulate

File System Operations File and directory creation and deletion Support of primitives to manipulate files and directories Mapping of files onto secondary storages Backup of files on stable, nonvolatile storage media n n 9 Chapter 3

Secondary Storage Management n OS provides secondary storage to backup memory u u n

Secondary Storage Management n OS provides secondary storage to backup memory u u n OS responsibility includes: u 10 Disks are the principal on-line storage medium, for both programs and data Proper management of disk storage is of central importance to a computer systems Free-space management, storage allocation and disk scheduling Chapter 3

Security and Protection (not to be discussed further) n Access control to resources u

Security and Protection (not to be discussed further) n Access control to resources u Forbid intruders (unauthorized users) to enter the system u Forbid user processes to access resources which they are not authorized to u Protect users and OS from each others F Memory addressing hardware ensures that a process can execute within its address space 11 Chapter 3

System Calls n System calls provide the interface between a process and the OS

System Calls n System calls provide the interface between a process and the OS u System calls can be available as assembly language instructions, or made directly from a higher-level language such as C, Pascal, … F 12 read(), write(), …. Chapter 3

Parameter Passing n Three methods are used to pass parameters Using registers u Using

Parameter Passing n Three methods are used to pass parameters Using registers u Using block table (Figure) u Using stack u F Parameters are pushed onto stack by the program and popped off the stack by OS X X: parameters For call Use parameters From table X Load address X System call 13 System Call 13 Code User Program 13 register Chapter 3 Op. Sys.

System Call Categories n Process Control Primitives u n File Manipulation Primitives u n

System Call Categories n Process Control Primitives u n File Manipulation Primitives u n get_time(), system data, file or device attributes Communication Primitives u 14 request(), read(), mount(), … Information Maintenance Primitives u n create(), open(), read(), write(), … Device Manipulation Primitives u n create(), execute(), wait(), … send(), receive(), … Chapter 3

System Structure n Because of their complexity, OS systems are usually structured as a

System Structure n Because of their complexity, OS systems are usually structured as a series of levels u n n Each level performs a certain subset of functions Each level relies on the next lower level to perform more primitive functions u n 15 The problem is decomposed into a number of more manageable sub problems The lowest level is the hardware Well defined interfaces: one level can be modified without affecting other levels Chapter 3

Possible OS Design Structure Level Name Objects Example Operations 13 Shell User programming environment

Possible OS Design Structure Level Name Objects Example Operations 13 Shell User programming environment Statements in shell language 12 User processes Quit, kill, suspend, resume 11 Directories Create, destroy, attach, detach, search, list 10 Devices External devices, such Create, destroy, open, close, as printer, displays read, write and keyboards 9 File system Files Create, destroy, open, close read, write 8 Communications Pipes Create, destroy, open. close, read, write 16 Chapter 3

Possible OS Design Structure Level Name Objects Example Operations 7 Virtual Memory Segments, pages

Possible OS Design Structure Level Name Objects Example Operations 7 Virtual Memory Segments, pages Read, write, fetch 6 Local secondary store Blocks of data, device Read, write, allocate, free channels 5 Primitive processes Primitive process, semaphores, ready list Suspend, resume, wait, signal Below this, there are the hardware layers. Note, however, that what is done by hardware and what is done by software varies from machine to machine. 17 Chapter 3

Hardware Layers Level Name Objects Example Operations 4 Interrupts Interrupt-handling programs Invoke, mask, unmask,

Hardware Layers Level Name Objects Example Operations 4 Interrupts Interrupt-handling programs Invoke, mask, unmask, retry 3 Procedures, call stack Mark stack, call, return 2 Instruction Set Evaluation stack, micro. Load, store, add, program interpreter, subtract, branch scalar and array data 1 Electronic circuits Registers, gates, buses, Clear, transfer, activate, etc. complement 18 Chapter 3

Characteristics of Modern Operating Systems n New design elements were introduced recently: u In

Characteristics of Modern Operating Systems n New design elements were introduced recently: u In response to new hardware developments F multiprocessor machines F high-speed networks F faster processors and larger memory u In response to new software needs F Client/Server applications F Internet and Web access F Multimedia applications 19 Chapter 3

Policies and Mechanisms n One important principle is the separation of policy from mechanism

Policies and Mechanisms n One important principle is the separation of policy from mechanism Policy decide what will be done u Mechanisms determine how it is done u n Microkernel based operating systems take the separation of mechanism and policy to extreme Implement a set of policy-free primitive building blocks u More advanced mechanisms and policies can be added via user-created kernel modules, or user programs u 20 Chapter 3

Microkernel architecture n Only a few essential functions in the kernel: u primitive memory

Microkernel architecture n Only a few essential functions in the kernel: u primitive memory management (address space) u Interprocess communication (IPC) u basic scheduling n Other OS services are provided by processes running in user mode (servers) u device n drivers, file system, virtual memory… More flexibility, extensibility, portability… 21 Chapter 3

Multithreading n n n A process is a collection of one or more threads

Multithreading n n n A process is a collection of one or more threads that can run simultaneously All threads within the same process share the same data and resources and a part of the process’s execution context It is easier to create or destroy a thread or switch among threads (of the same process) than to do the same among processes 22 Chapter 3