operating system structure

11,031 views

Published on

Published in: Education
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
11,031
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
299
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

operating system structure

  1. 1. Operating-System Structures System Components Operating System Services System Calls System Programs System Structure Virtual Machines System Design and Implementation System Generation
  2. 2. Common System Components Process Management Main Memory Management File Management I/O-System Management Secondary-Storage Management Networking Protection System Command-Interpreter System
  3. 3. Process Management A process is a program in execution. A process is an active entity. A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task. Initialization data is also passed for execution of a process. A program can have many processes as it runs. System processes execute OS code whereas user processes execute user code. OS reclaims reusable resources from the process on its termination. The OS is responsible for the following activities in connection with process management:  Process creation and deletion.  process suspension and resumption.  Provision of mechanisms for:  process synchronization  process communication  deadlock handling
  4. 4. Main-Memory Management Memory is a large array of words or bytes, each with its own address. It is a repository of quickly accessible data shared by the CPU and I/O devices. Main memory is a volatile storage device. It loses its contents in the case of system failure. The I/O operations implemented via DMA also read and write in memory. Main-memory is frequently addressed by CPU for accessing instructions and data from memory during program execution. Different memory-management techniques are used to keep several programs in memory for improving CPU utilization and response time. An appropriate memory-management scheme is used for a specific hardware design of the system. The operating system is responsible for the following activities in connection with memory management:  Keep track of which parts of memory are currently being used and by whom.  Decide which processes to be loaded when memory space becomes available.  Allocate and deallocate memory space as needed.
  5. 5. File Management A file is a collection of related information defined by its creator. Commonly, files represent programs (both source and object forms) and data. Computers can store files on HD, FD, MD, OD or magnetic tape/ drum. Each media has its own characteristics, device controller and properties such as access speed, capacity, data-transfer rate, and access-method (random or sequential). OS maps files (logical storage units) onto physical media and accesses these files via the storage devices. OS manages the mass storage media and the devices that control them and provides protection to files in multi-user environment. The operating system is responsible for the following activities in connection with file management:  File creation and deletion.  Directory creation and deletion.  Support of primitives for manipulating files and directories.  Mapping files onto secondary storage.  File backup on stable (nonvolatile) storage media.
  6. 6. I/O System Management OS hides the peculiarities of specific hardware of I/O devices from the user. The I/O system consists of:  A memory-management component that includes buffereing, caching, and spooling.  A general device-driver interface.  Drivers for specific hardware devices. The device-driver knows the peculiarities of the specific device to which it is assigned. Interrupt handlers and device drivers are used in the construction of efficient I/O subsystems. The I/O subsystem interfaces to other system components, manages devices, transfers data, and detects I/O completion.
  7. 7. Secondary-Storage Management Since main memory (primary storage) is volatile and too small to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory. Secondary-storage devices are used to store data and programs of the users. Application programs (compilers, assemblers, editors, AutoCAD etc.) are commonly available on FDs, CDs, HDs, Ods etc. Most modern computer systems use disks as the principal on-line storage medium, for both programs and data. OS uses optimal techniques for secondary-storage management in order to increase its efficiency. The operating system is responsible for the following activities in connection with disk management:  Free space management.  Storage allocation.  Disk scheduling.
  8. 8. Networking (Distributed Systems) A distributed system is a collection of processors (PCs, workstations, minicomputers, large and general purpose computer systems) that do not share memory or a clock. Each processor has its own local memory and clock. The processors in the system are connected through communication lines (high speed buses or networks). Communication takes place using a protocol (FTP, NFS, TCP/IP) which have a great effect on the system’s utility and popularity. The communication network design considers routing, connection strategies, problems of contention, and security. Os provides network access using network interface’s device drivers. A distributed system provides user access to various system resources. WWW provides a new access method for information sharing using http - for use in communication between a web server and a web browser. Access to a shared resource allows:  Computation speed-up.  Increased functionality.  Increased data availability.  Enhanced reliability.
  9. 9. Protection System Users must be protected during the concurrent execution of multiple processes. OS’s authorization is required to utilize the resources (i.e. files, memory segments, CPU, plotters, printers, tapes). Different mechanisms are used to provide to different resources. Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources. The protection mechanism must:  distinguish between authorized and unauthorized usage.  specify the controls to be imposed.  provide a means of enforcement.  Improves reliability by detecting errors at an early stage.
  10. 10. Command-Interpreter System Most important system component being an interface between the user and OS. In some systems it is in the kernel while in other OSs (MS DOS, UNIX), it is a special program that runs when a job is initiated or when user logs-on. Named as command.com in MSDOS and shell in UNIX. In these OSs, commands are typed and entered for execution by the user. In latest OSs, User-friendly interface style has been incorporated to facilitate the users. Many commands are given to the operating system by control statements which deal with:  process creation and management  I/O handling  secondary-storage management  main-memory management  file-system access  protection  networking
  11. 11. Operating System Services OS services for convenience of the users/programmers:-  Program execution – system capability to load a program into memory, run, and end it normally or abnormally.  I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O.  File-system manipulation – program capability to read, write, create, and delete files.  Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing approaches.  Error detection – ensures correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. OS services for ensuring efficient system operations:-  Resource allocation – allocating resources to multiple users or multiple jobs running at the same time.  Accounting – keep track of which users use how many and which kinds of computer resources for account billing or for accumulating usage statistics.  Protection – ensuring that all access to system resources is controlled.
  12. 12. System Calls System calls provide the interface between a process and the OS:  Generally available as assembly-language instructions.  Languages defined to replace assembly language for systems programming allow system calls to be made directly (e.g., C, C++). A system call is used to complete a specific task:  Reading input file name  Opening a file  Error message if any  Abnormal termination  Deletion of a file  Prompting a message  Reading data for the file  Writing data to the file or console  Closing the file  Normal termination Three general methods are used to pass parameters between a running program and the operating system:  Pass parameters in registers.  Store the parameters in a table in memory, and the table address is passed as a parameter in a register (used in linux)  Push (store) the parameters onto the stack by the program, and pop off the stack by OS.
  13. 13. Passing of Parameters as a Table
  14. 14. Types of System Calls Process control  End, Abort  Load, Execute  Create process, Terminate process  Get process attributes, Set process attributes  Wait for time  Wait event, Signal event  Allocate memory, Free memory File management  Create file, Delete file  Open, Close  Read, Write, Reposition  Get file attributes, Set file attributes Device management  Request device, Release device  Read, Write, Reposition  Get device attributes, Set device attributes  Logically attach devices, Logically detach devices
  15. 15. Types of System Calls Information maintenance  Get time or date, Set time or date  Get system data, Set system data  Get process, file, or device attributes, Set process, file, or device attributes Communications  Create communication connection, Delete communication connection  Send messages, Receive messages  Transfer status information  Attach remote devices, Detach remote devices
  16. 16. MS-DOS ExecutionAt System Start-up Running a Program
  17. 17. UNIX Running Multiple Programs
  18. 18. Communication Models Communication may take place using either message passing or shared memory. Message Passing Shared Memory
  19. 19. System Programs System programs are user interfaces to system calls and provide a convenient environment for program development and execution. Categories of system programs are :-  File Manipulation – used for creating, deleting, renaming, printing, dumping, listing, and generally manipulating files and directories.  Status Information – ask the system for date, time, available memory/disk, used memory/disk, number of users etc.  File Modification – text editors to create and modify the content of files stored on disk or tape.  Programming Language Support – compilers, assemblers, and interpreters for common programming languages are provided to the user with the OS.  Program Loading and Execution – OS may provide absolute loaders, relocatable loaders, linkage editors, and debuggers for program loading and execution.  Communications – provide mechanism for creating virtual connections among processes, users, and different computer systems which allows message passing, browse web pages, send e-mail messages, log-in remotely, transfer files from one machine to another.  Application Programs or System Utilities – many OSs are supplied with system utilities or application programs (i.e. web browsers, word processors, text formatters, spreadsheets, database systems) to perform common operations.
  20. 20. System Programs Most users’ view of the operation system is defined by system programs, not by the actual system calls. Command-interpreter is the most important system program and can be implemented in two ways:-  Schemes of commands implementation are:  Command interpreter itself contains the code to execute the commands, jumps to a section of its code that sets up the parameters, and makes the appropriate system call.  Advantages: faster execution; easy to use by the programmers.  Disadvantages: bigger size of the command-interpreter; needs changes for new commands.  All commands are implemented through special system programs. Command file is loaded in the memory and executed.  Advantages : small size of command interpreter; not changed for new commands, new commands can be incorporated easily.  Disadvantages : clumsy task of passing parameters from the command-interpreter to the system program; slower in loading and execution; misinterpretation of the command parameters as they are designed and implemented at different times by different programmers.
  21. 21. Simple System Structure (MS-DOS) MS-DOS was written to provide the most functionality in the least space. It was not divided into modules carefully. Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated.
  22. 22. Simple System 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  Systems programs are provided to define the user interface.  The kernel  Consists of everything below the system-call interface and above the physical hardware.  Separated into a series of interfaces and device drivers.  Different components (file system, CPU scheduling, memory management and other OS functions) were layered in its design.  OS may provide smaller modules for much greater control of computer resources, incorporating changes in the separate modules easily to enhance functionality and hide information in different components.
  23. 23. UNIX System Structure
  24. 24. 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. OS has a greater control over the computer resources and applications that make use of it. Provides more freedom to the implementers to make changes in the inner workings of the system. Provides information hiding by allowing the programmers to implement the low-level routines using top-down modular programming approach. Layered approach is used for modularization of the OS. Higher-level layers can invoke lower-level layers. Less number of layers provide more functionality at each level while reducing the problems.
  25. 25. Layered Approach Advantages: modularization makes debugging and verification much easier; design and implementation is simplified; each layer hides certain data structures, operations and hardware details from higher-level layers. Disadvantages: level definition and implementation is very difficult; order of levels for the design of layered structure is problematical; interaction between layers and passing of parameters / data is very complex; less efficient as a system call takes longer time for execution than a non-layered system. Examples: Technische Hogeschool Eindhoven (THE) OS and Venus layer structure.
  26. 26. An Operating System Layer
  27. 27. Level 5: User programs Level 4: buffering for input and output devices Level 3: operator-console device driver Figure : THE layer structure Level 2: memory management Level 1: CPU scheduling Level 0: hardwareLevel 6: User programsLevel 5: device drivers and schedulersLevel 4: virtual memoryLevel 3: I/O channel Figure : Venus layer structureLevel 2: CPU schedulingLevel 1: instruction interpreterLevel 0: hardware
  28. 28. Layered Approach OS/2 provides multitasking and dual mode operation on more powerful hardware. OS/2 does not provide direct user access to low- level facilities like DOS, OS has more control over the hardware, and has more information about usage of resources. Windows NT 4.0 has increased its performance by moving layers from user space to kernel space and closely integrating them.
  29. 29. OS/2 Layer Structure
  30. 30. Microkernel System Structure Larger kernels need more space and are difficult to manage. Microkernel approach moves all non-essential components from the kernel and implements them as system-level programs and user- level programs, moving as much from the kernel into “user” space. Microkernel provides minimal process memory management and communication facility. Microkernel provides communication facility through message- passing between the client program and various services that are also running in the user space. Microkernel provides indirect communication between the client program and the service. Benefits:  easier to extend a microkernel  fewer changes required in the modification of microkernel  easier to port the operating system to new architectures  more reliable (less code is running in kernel mode)  more secure – if a routine fails, the rest of the OS remains untouched
  31. 31. Windows NT Client-Server Structure
  32. 32. Virtual Machines The layered approach is taken to its logical conclusion in the concept of a virtual machine. The virtual machine concept treats the kernel of the OS and the hardware though they were all hardware. System programs treat hardware instructions and system calls as they were at the same level. Application programs can also call system programs. A virtual machine provides an interface identical to the underlying bare hardware. The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory.
  33. 33. Virtual Machines The resources of the physical computer are shared to create the virtual machines:  CPU scheduling can create the appearance that users have their own processor.  Spooling and a file system can provide virtual card readers and virtual line printers.  A normal user time-sharing terminal serves as the virtual machine operator’s console. A virtual machine has virtual memory, virtual disks, virtual printer, virtual console, virtual processor and virtual communication network. A user can run any type of software package on his/her virtual machine. The virtual machine software is concerned with multiprogramming multiple virtual machines onto a physical machine. Virtual disks (minidisks) are difficult to implement in a virtual machine. A lot of effort is required to provide an exact duplicate of the underlying machine. Virtual user mode and virtual monitor mode run in the physical user mode.
  34. 34. Virtual Machines Advantages  The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines.  A virtual-machine system is a perfect vehicle for operating- systems research and development. System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation.  Virtual machines are useful for solving system compatibility problems. Disadvantages  No direct sharing of resources as each virtual machine is isolated from all other virtual machines.  The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine.  The privileged instructions (needed mainly for I/O) must be simulated and hence execute more slowly.
  35. 35. System ModelsNon-virtual Machine Virtual Machine
  36. 36. Java Virtual Machine In addition to a language specification and a large API library, Java also provides a specification for a Java Virtual Machine (JVM). For each Java class, the Java compiler produces an architecture- neutral bytecode output (.class) file that will run on any implementation of the JVM. JVM consists of: - class loader - class verifier - runtime interpreter The Java interpreter may be a software module that interprets the byte-codes one at a time, or it may be a Just-In-Time (JIT) compiler that turns the architecture-neutral bytecodes into native machine language for the host computer. Most implementations of the JVM use a JIT compiler for enhanced performance. JVM design provides a secure, efficient, object-oriented, portable, and architecture-neutral platform on which to run Java programs.
  37. 37. Java Virtual Machine
  38. 38. System Design Goals System goals and specifications are required to be defined for the design of OS. Choice of hardware and type of OS to be decided. Requirements of OS can be divided in two groups:  Goals desired by users: the system should be convenient and easy to use; easy to learn; reliable; safe, and fast.  Goals desired by programmers / designers: easy to design, implement, maintain and operate; it should be flexible; reliable; error free, and efficient. The wide range of systems shows that different requirements can result in a large variety of solutions for different environments.
  39. 39. System Mechanisms and Policies Mechanisms determine how to do something and policies decide what will be done. Timer used in the CPU protection is a mechanism and the time to be set for a particular user is a policy decision. Mechanisms and policies should be treated separately – an important principle. Policies do change from time to time or place to place but mechanisms rarely change. Policy-independent mechanisms are incorporated for flexibility. Policy decisions must be made for all resource- allocation and scheduling problems.
  40. 40. System Implementation Designed OS is implemented using either assembly language or a high level language. Both languages can be used in the implementation of an OS. Traditionally written in assembly language, operating systems can now be written in higher-level languages (MCP in ALGOL, MULTICS in PL/1 PRIMOS in FORTRAN, and Unix, OS/2 and Windows in C). Advantages of using a high level language: code writing is much faster; more compact; easier to understand; easier to debug; OS is far easier to port; better data structures and algorithms provide performance improvements. Disadvantages of using a high level language: reduced speed, and increased storage requirements. The most critical or bottleneck routines (memory manager, CPU scheduler) can be written in assembly language for obtaining better performance with small code. Trace listings of system behaviour (using log file or real time approach) and analysis program help to identify bottlenecks and inefficiencies.
  41. 41. System Generation (SYSGEN) As the OSs are designed to run on any of a class of machines at a variety of sites with a variety of peripheral configurations, the system must be configured or generated for each specific computer site. This process is known as SYSGEN. The SYSGEN program reads from a file or asks the operator for following information concerning the specific configuration of the hardware system or probes the hardware directly to determine the type of components:  CPU type: options for instruction sets; description of each CPU for multiple CPU systems.  Memory: total memory, available memory - normally determined by the system.  Devices: total devices, system needs to know the device number, the device interrupt number, type and model of each device.  Options: Desired options of the OS and parameters values needed (buffers and their sizes, CPU scheduling algorithm, maximum number of processes to be supported).
  42. 42. System Generation Approaches Approaches  The source code of the OS is modified and the OS is completely compiled to meet requirements of the described system – fully tailored OS (one extreme).  The system description could cause the creation of tables and the selection of modules from a precompiled library. These modules would be linked to form the generated OS. SYSGEN is faster but has more generality that was actually needed.  A completely table driven system can be constructed. All the code would always be a part of the system and selection would occur at execution time, not at a compile or link time – another extreme. The major differences among these approaches are the size, generality of the generated system, and the ease of modification as the hardware configuration changes. Bootstrap program or Bootstrap loader locates the kernel, loads it into main memory and starts the execution. So OS is made available for use by the hardware and users.

×