Chapter 2 Operating System Overview Ninth Edition By William Stallings Operating Systems: Internals and Design Principles © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Operating System ■ A program that controls the execution of application programs ■ An interface between applications and hardware Main objectives of an OS: • Convenience • Efficiency • Ability to evolve © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Operating System Services ■ Program development ■ Program execution ■ Access I/O devices ■ Controlled access to files ■ System access ■ Error detection and response ■ Accounting © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Key Interfaces ■ Instruction set architecture (ISA) ■ Application binary interface (ABI) ■ Application programming interface (API) © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
The Operating System as Resource Manager ■ The OS is responsible for controlling the use of a computer’s resources, such as I/O, main and secondary memory, and processor execution time © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Operating System as Resource Manager ■ Functions in the same way as ordinary computer software ■ Program, or suite of programs, executed by the processor ■ Frequently relinquishes control and must depend on the processor to allow it to regain control © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Evolution of Operating Systems ▪A major OS will evolve over time for a number of reasons: Hardware upgrades New types of hardware New services Fixes © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Evolution of Operating Systems ▪ Stages include: Serial Processin g Simple Batch Systems Multiprogrammed Batch Systems Time Sharing Systems © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Serial Processing Earliest Computers: ■ No operating system ■ Programmers interacted directly with the computer hardware ■ Computers ran from a console with display lights, toggle switches, some form of input device, and a printer ■ Users have access to the computer in “series” Problems: ■ Scheduling: ■ Most installations used a hardcopy sign-up sheet to reserve computer time ■ Time allocations could run short or long, resulting in wasted computer time ■ Setup time ■ A considerable amount of time was spent on setting © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved. up the program to run
Simple Batch Systems ■ Early computers were very expensive ■ Important to maximize processor utilization ■ Monitor ■ User no longer has direct access to processor ■ Job is submitted to computer operator who batches them together and places them on an input device ■ Program branches back to the monitor when finished © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Monitor Point of View ■ Monitor controls the sequence of events ■ Resident Monitor is software always in memory ■ Monitor reads in job and gives control ■ Job returns control to monitor © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Processor Point of View ■ Processor executes instruction from the memory containing the monitor ■ Executes the instructions in the user program until it encounters an ending or error condition ■ “Control is passed to a job” means processor is fetching and executing instructions in a user program ■ “Control is returned to the monitor” means that the processor is fetching and executing instructions © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved. from the monitor program
Job Control Language (JCL) Special type of programming language used to provide instructions to the monitor What compiler to use What data to use © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Desirable Hardware Features • While the user program is executing, it must not alter the memory area containing the monitor Memory protection • Prevents a job from monopolizing the system Timer • Can only be executed by the monitor Privileged instructions • Gives OS more flexibility in controlling user programs Interrupts © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Modes of Operation User Mode • User program executes in user mode • Certain areas of memory are protected from user access • Certain instructions may not be executed Kernel Mode • Monitor executes in kernel mode • Privileged instructions may be executed • Protected areas of memory may be accessed © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Simple Batch System Overhead ■ Processor time alternates between execution of user programs and execution of the monitor ■ Sacrifices: ■ Some main memory is now given over to the monitor ■ Some processor time is consumed by the monitor ■ Despite overhead, the simple batch system improves utilization of the computer © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Multiprogrammed Batch Systems Processor is often idle Even with automatic job sequencin g I/O devices are slow compared to processor © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Uniprogramming The processor spends a certain amount of time executing, until it reaches an I/O instruction; it must then wait until that I/O instruction concludes before proceeding © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Multiprogramming ■ There must be enough memory to hold the OS (resident monitor) and one user program ■ When one job needs to wait for I/O, the processor can switch to the other job, which is likely not waiting for I/O © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Multiprogramming ■ Also known as multitasking ■ Memory is expanded to hold three, four, or more programs and switch among all of them © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Multiprogramming Example Table 2.1 Sample Program Execution Attributes © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved. Table 2.2 Effects of Multiprogramming on Resource Utilization
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Time-Sharing Systems ■ Can be used to handle multiple interactive jobs ■ Processor time is shared among multiple users ■ Multiple users simultaneously access the system through terminals, with the OS interleaving the execution of each user program in a short burst or quantum of © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved. computation
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved. Table 2.3 Batch Multiprogramming versus Time Sharing
pTime-Sharing System (CTSS) © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved. ■ One of the first time-sharing operating systems ■ Developed at MIT by a group known as Project MAC ■ The system was first developed for the IBM 709 in 1961 ■ Ran on a computer with 32,000 36-bit words of main memory, with the resident monitor consuming 5000 of that ■ Utilized a technique known as time slicing ■ System clock generated interrupts at a rate of approximately one every 0.2 seconds ■ At each clock interrupt the OS regained control and could assign the processor to another user ■ Thus, at regular time intervals the current user would be preempted and another user loaded in ■ To preserve the old user program status for later resumption, the old user programs and data were written out to disk before the new user programs and data were read in ■ Old user program code and data were restored in main memory when that program was next given a turn
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Major Achievements ■ Operating Systems are among the most complex pieces of software ever developed ■ Major advances in development include: ■ Processes ■ Memory management ■ Information protection and security ■ Scheduling and resource management ■ System structure © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Process ■ Fundamental to the structure of operating systems A process can be defined as: A program in execution An instance of a running program The entity that can be assigned to, and executed on, a processor A unit of activity characterized by a single sequential thread of execution, a current state, and an associated set of system resources © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Causes of Errors ■ Nondeterminate program operation ■ When programs share memory, and their execution is interleaved by the processor, they may interfere with each other by overwriting common memory areas in unpredictable ways ■ The order in which programs are scheduled may affect the outcome of any particular program ■ Deadlocks ■ It is possible for two or more programs to be hung up waiting for each other ■ Improper synchronization ■ It is often the case that a routine must be suspended awaiting an event elsewhere in the system ■ Improper design of the signaling mechanism can result in loss or duplication ■ Failed mutual exclusion ■ More than one user or program attempts to make use of a shared resource at the same time ■ There must be some sort of mutual exclusion mechanism that permits only one routine at a time to perform an update against the file © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Components of a Process ■ The execution context is essential: ■ It is the internal data by which the OS is able to supervise and control the process ■ Includes the contents of the various process registers ■ Includes information such as the priority of the process and whether the process is waiting for the completion of a particular I/O event ■ A process contains three components: ■ An executable program ■ The associated data needed by the program (variables, work space, buffers, etc.) ■ The execution context (or “process state”) of the program © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Process Management ▪ The entire state of the process at any instant is contained in its context ▪ New features can be designed and incorporated into the OS by expanding the context to include any new information needed to support the feature © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Memory Management ■ The OS has five principal storage management responsibilities: Process isolation Automatic allocation and management Support of modular programming Protection and access control Long-term storage © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Virtual Memory ■ A facility that allows programs to address memory from a logical point of view, without regard to the amount of main memory physically available ■ Conceived to meet the requirement of having multiple user jobs reside in main memory concurrently © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Paging ■ Allows processes to be comprised of a number of fixed-size blocks, called pages ■ Program references a word by means of a virtual address, consisting of a page number and an offset within the page ■ Each page of a process may be located anywhere in main memory ■ The paging system provides for a dynamic mapping between the virtual address used in the program and a real address (or physical address) in main memory© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Information Protection and Security ■ The nature of the threat that concerns an organization will vary greatly depending on the circumstances ■ The problem involves controlling access to computer systems and the information stored in them Main issue s Availability Confidentiality Data integrity Authenticity © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Scheduling and Resource Management ■ Key responsibility of an OS is managing resources ■ Resource allocation policies must consider: Fairness Differential responsivene ss Efficiency © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Different Architectural Approaches ■ Demands on operating systems require new ways of organizing the OS • Microkernel architecture • Multithreading • Symmetric multiprocessing • Distributed operating systems • Object-oriented design Different approaches and design elements have been tried: © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Microkernel Architecture ■ Assigns only a few essential functions to the kernel: ■ The approach: Address space managemen t Interprocess communication (IPC) Basic scheduling Simplifies implementation Provides flexibility Well suited to a distributed environment © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Multithreading ■ Technique in which a process, executing an application, is divided into threads that can run concurrently Thread Dispatchable unit of work Includes a processor context and its own data area for a stack Executes sequentially and is interruptible Proces s A collection of one or more threads and associated system resources By breaking a single application into multiple threads, a programmer has greater control over the modularity of the application and the timing of application-related events © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Symmetric Multiprocessing (SMP) ■ Term that refers to a computer hardware architecture and also to the OS behavior that exploits that architecture ■ The OS of an SMP schedules processes or threads across all of the processors ■ The OS must provide tools and functions to exploit the parallelism in an SMP system ■ Multithreading and SMP are often discussed together, but the two are independent facilities ■ An attractive feature of an SMP is that the existence of multiple processors is transparent to the user © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
SMP Advantages Performanc e More than one process can be running simultaneously, each on a different processor Availability Failure of a single process does not halt the system Incremental Growth Performance of a system can be enhanced by adding an additional processor Scaling Vendors can offer a range of products based on the number of processors configured in the system © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
© 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
OS Design Distributed Operating System ■ Provides the illusion of a single main memory space and a single secondary memory space plus other unified access facilities, such as a distributed file system ■ State of the art for distributed operating systems lags that of uniprocessor and SMP operating systems Object-Oriented Design ■ Lends discipline to the process of adding modular extensions to a small kernel ■ Enables programmers to customize an operating system without disrupting system integrity ■ Also eases the development of distributed tools and full-blown distributed operating systems © 2017 Pearson Education, Inc., Hoboken, NJ. All rights reserved.