IT2164/IT2561 Operating Systems and Administration Chapter 2 PDF

Document Details

RationalDaisy622

Uploaded by RationalDaisy622

Nanyang Polytechnic

null

null

Tags

operating systems computer science operating system organization computer architecture

Summary

This document is a chapter on operating system organization. It covers topics such as operating system services, functions, and implementation mechanisms. It discusses concepts and architectures of operating systems.

Full Transcript

IT2164/IT2561 Operating Systems and Administration Chapter 2 Operating System Organization Operating System Organization At the end of this chapter, you should be able to List and describe the common services offered by an OS Describe the functions of an operating system Understand t...

IT2164/IT2561 Operating Systems and Administration Chapter 2 Operating System Organization Operating System Organization At the end of this chapter, you should be able to List and describe the common services offered by an OS Describe the functions of an operating system Understand the operating system requirements Describe the basic operating system organization Explain the general implementation issues and implementation mechanisms Understand modern OS architecture 2 Operating System Services An operating system provides an environment for the execution of programs Different operating systems are organized along different lines As such, specific services may differ, but common classes exist  Those that provide convenience for user/programmer  Those that ensure efficient operations of the system 3 Operating System Services Services that provides convenience to user/programmer  User interface Batch interface, command line interface, GUI  Program execution Able to load, run and terminate a program  Input/Output operations File, CD/DVD drive, Display device, SmartCard  File-system manipulation Create/Read/Write/Delete files and directories Permission management  Communications Local/remote inter-process communication  Error detection Able to detect error and take proper action to ensure consistent computing 4 Operating System Services Services that ensures efficient operation of the system  Resource allocation Resources to be allocated among multiple users fairly Different algorithms for different resources  Accounting Keep track of usage statistics eg CPU, Printer, Harddisk quota Reconfigure system to improve computing services  Protection and security Security of system from outsiders Ensure access to all system resources is controlled Audit trail of access 5 Functions of an Operating System Regardless of services offered, there are four major group of basic functions common to all OS  Device management  Process, thread and resource management  Memory management  File management 6 Basic Operating System Organization Based on the four functions, the modern OS implements 4 major managers, which provides abstractions to the respective resource that they manage.  Process, Thread and Resource Manager  Memory Manager  Device Manager  File Manager Close interactions between the four managers 7 Device Management Refers to the way generic devices are handled. Includes disk, tapes, terminals, printers etc Special management approaches for processor and memory Partitioning design simplifies adding and upgrading of devices 8 Process, Thread and Resource Management Creates abstractions of processes, threads, resources Allocates processor resource equitably Allocates and tracks abstract resource such as queues, semaphores, messages Cooperates with memory manager to administer the primary memory 9 Process, Thread, and Resource Management Thread Abstraction Process Generic Abstraction Resource Multiprogramming Manager Other Primary Memory … Abstract Resources Processor 10 Memory Management Administer and allocate primary memory Enforces resource isolation Enables sharing between processes Provides virtual memory extensions  Abstract machine’s memory appear larger than physical memory 11 Memory Management Isolation & Sharing Virtual Memory Block Process Allocation Manager Primary Storage Memory Devices 12 File Management Creates abstraction of storage devices i.e. I/O operations Range from byte stream files to indexed records Local and Remote file systems 13 Basic Operating System Organization File Manager Process, Thread & Resource Manager Memory Device Manager Manager Processor(s) Main Memory Devices 14 Key OS Requirements Coordinate Use Processes of the Abstractions The Abstractions Create the Abstractions 15 OS Requirements Manage resource sharing  Time/space-multiplexing Using time/space-multiplexing where appropriate.  Exclusive use of a resource Allow processes to use a resource exclusively as required.  Isolation Allow a resource to save information without fear of it being modified or tampered with.  Managed sharing Sharing must be done in an orderly fashion according to the properties of the resource. E.g., printer vs disk drive. 16 Implementation mechanisms Three basic mechanisms to address isolation and sharing : Processor modes Kernels Method of invoking system service 17 Processor Modes Distinguish between trusted and un-trusted software Determine execution capability and accessible memory areas Modern processors provide 2 modes Mode bit: Supervisor or User mode Supervisor mode (for OS)  Can execute all machine instructions  Can reference all memory locations User mode (for user programs)  Can only execute a subset of instructions  Can only reference a subset of memory locations 18 Processor Modes - Execution capability Processor in supervisor mode can execute all instructions Including privileged instructions. (Also called supervisor or protected.) Examples of privileged instructions :  I/O instructions  Memory-related instructions  Processor mode-change instructions Processor in user mode can execute only non- privileged instructions. 19 Processor Modes - Accessible memory Processor in supervisor mode can access all memory locations:  System (or supervisor, kernel or protected) space which refers memory area used by the OS  User space refers to memory area used by application processes Processor in user mode can access only user space 20 Processor Modes: Supervisor and User Memory User User Process Space Supervisor Process Supervisor Space 21 Processor Modes Trusted OS software executes in supervisor mode All other software (including some parts of the OS) executes in user mode Concept allows for OS to be able to control access to resources  User programs have to ask the OS to execute privileged instructions on their behalf.  Any particular configuration can isolate or permit sharing or resources according to the administrator’s policy 22 Kernels The part of the OS critical to correct operation (trusted software) Implements the basic mechanisms that assure secure operation of entire OS Executes in supervisor mode The trap instruction is used to switch from user to supervisor mode, entering the OS 23 Requesting Services from OS In order to execute privileged instructions, user programs have to activate routines in the kernel, which can then execute on the user programs’ behalf. Two techniques :  Systemcall  Message passing 24 System Call In system call, the relevant function is activated via a trap instruction. OS provides a sub function which the user program calls Stub function will switch the processor to supervisor mode It will execute the trap instruction by branching to a trap table to the entry point of the system function to be invoked On completion, processor is switched back to user mode and control returns to user process Appears as ordinary function call to the application programmer 25 Message Passing In the message passing method, the user program constructs a message that requests the desired service. Uses OS send() system call OS kernel implements target function Kernel process must be started or active i.e. must be in supervisor mode, to receive message User process waits for result with receive() operation Kernel sends message back to user process on completion 26 System Call versus Message Passing In system call, the user process/thread gains ability to execute privileged instructions In the message passing method, the system function is executed by the kernel process/thread System calls are more efficient than message passing.  Message passing has cost of message formation/copying and process multiplexing  System calls just requires a trap command. Most modern systems use system calls. 27 System Call and Message Passing Operating Systems send(…, A, …); call(…); receive(…, B, …); trap send/receive receive(…A, …); return; … send(…, B, …); Procedure Call Message Passing 28 System Call Using the trap Instruction OS provides a procedure stub for user programs to execute, which will then be translated into the actual … function via the trap table. fork(); … Trap Table Kernel fork() { … trap N_SYS_FORK() … sys_fork() } The trap function relies on the trap table to tell it the entry point of the relevant sys_fork() { OS function. In this case, the trap table is consulted … and the address of return; sys_fork() is found so that } the function can be executed. 29 A Thread Performing a System Call User Space Kernel Space Thread fork(); sys_fork() { } 30 Modern OS architecture A modular OS architecture implements each manager in its own software module Interaction among various managers via abstract data type Frequent calls incurs performance penalty Sacrifice modularity for performance  Monolithic kernel implementation Four basic modules are combined into a single software module  Microkernel approach Employs a small kernel that implements only the essential and critical functions Reminder functions are implemented outside kernel, possibly in separate modules 31 The UNIX Architecture Interactive User Application Libraries Commands Programs … OS System Call Interface Trap Table Device Driver Driver Interface Device Driver Monolithic Kernel Module Process Management … Memory Management File Management Device Driver Device Mgmt Infrastructure 32 Windows NT Organization Process Process T T T T T T T T Process T Process Management Libraries Memory Management Subsystem File Management Subsystem Subsystem Device Mgmt Infrastructure User Supervisor NT Executive NT Kernel I/O Subsystem Hardware Abstraction Layer Processor(s) Main Memory Devices 33 Conclusion OS implements an environment which includes processes, resources and facilities to manage resources. Modern OS incorporate managers for processes and resources, including memory, files and devices. Processor modes, kernels and a method of invoking system service allows the OS to achieve resource abstraction and sharing. 34

Use Quizgecko on...
Browser
Browser