KEMBAR78
An Overview of Operating Systems and algorithms.ppt
Chapter 1
Operating System
Overview
Operating System
Operating System
 A program that controls the execution of
application programs
 An interface between applications and hardware
OS objectives
OS objectives
 1.Convenient: OS is used for user services like Program
Execution, I/O operations, File System Manipulation,
Communications and Error Detection to execute in a
convenient manner.
 2. Efficient: OS has the capability to provide an
environment to run above user services in an efficient
manner. Batch processing, Multiprocessing,
multiprogramming, etc are some ways by which OS
increases efficiency.
 3. Ability to evolve: OS have the ability to evolve.
Evolution has been as following- Batch Operating System,
Time-sharing operating system, Distributed operating
system, Network operating system, Real time operating
system.
The OS as a
User/Computer Interface
 Computer Hardware-Software Structure
 Layered organization
 OS services to users
Operating System Services
Operating System Services
 One set of operating-system services provides functions that are helpful
to the user:
 User interface - Almost all operating systems have a user interface (UI)
 Varies between Command-Line (CLI), Graphics User Interface (GUI),
Batch
 Program execution - The system must be able to load a program into
memory and to run that program, end execution, either normally or
abnormally (indicating error)
 I/O operations - A running program may require I/O, which may involve a
file or an I/O device.
 File-system manipulation - The file system is of particular interest.
Obviously, programs need to read and write files and directories, create and
delete them, search them, list file Information, permission management.
Operating System Services
Operating System Services
(Cont.)
(Cont.)
 One set of operating-system services provides functions that are helpful
to the user (Cont):
 Communications – Processes may exchange information, on the same
computer or between computers over a network
 Communications may be via shared memory or through message passing
(packets moved by the OS)
 Error detection – OS needs to be constantly aware of possible errors
 May occur in the CPU and memory hardware, in I/O devices, in user
program
 For each type of error, OS should take the appropriate action to ensure
correct and consistent computing
 Debugging facilities can greatly enhance the user’s and programmer’s
abilities to efficiently use the system
Operating System Services
Operating System Services
(Cont.)
(Cont.)
 Another set of OS functions exists for ensuring the efficient operation of the system
itself via resource sharing
 Resource allocation - When multiple users or multiple jobs running
concurrently, resources must be allocated to each of them
 Many types of resources - Some (such as CPU cycles,mainmemory, and file
storage) may have special allocation code, others (such as I/O devices) may
have general request and release code.
 Accounting - To keep track of which users use how much and what kinds of
computer resources
 Protection and security - The owners of information stored in a multiuser or
networked computer system may want to control use of that information,
concurrent processes should not interfere with each other
 Protection involves ensuring that all access to system resources is controlled
 Security of the system from outsiders requires user authentication, extends to
defending external I/O devices from invalid access attempts
 If a system is to be protected and secure, precautions must be instituted
throughout it. A chain is only as strong as its weakest link.
A computer is a set of resources for
moving, storing, & processing data
The OS is responsible for managing
these resources
The OS exercises its control
through software
The Operating System as a
Resource Manager
Operating
System
as
Resource
Manager
OS as resource manager
OS as resource manager
 CPU: Perform execution of program – which is in high level
language.Compiled or executable program has to be executed by
CPUshould be brought into MM from disk.Because CPU can not
directly access SS. It can access MM directly.
 MM:Single memory block shared by multiple program of a
user/users. DOS/UNIX. When CPU find piece of program or data
on SS, it is duty of DD to bring it in MM.
 I/O devices:I/P-keyboard-feed data , Printer/monitor-O/P.
 Secondary storage-special I/O device.-File-R/W.
 So OS responsibility to manage these devices efficiently. So more
than 1 user can access those simultaneously.
 Modern OS-Distributed computing- Avoid duplicates copy, efficient
use of resources
Evolution of Operating
Evolution of Operating
Systems
Systems
 A major OS will evolve over time for a
number of reasons:
Evolution of
Evolution of
Operating Systems
Operating Systems
 Stages include:
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 just on setting
up the program to run
Simple Batch Systems
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
 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
Job Control Language
Job Control Language
(JCL)
(JCL)
User and kernel mode
User and kernel mode
 User Mode :The system is in user mode when the operating
system is running a user application such as handling a text editor.
The transition from user mode to kernel mode occurs when the
application requests the help of operating system or an interrupt
or a system call occurs.
 The mode bit is set to 1 in the user mode. It is changed from 1 to 0
when switching from user mode to kernel mode.
 Kernel Mode:The system starts in kernel mode when it boots and
after the operating system is loaded, it executes applications in
user mode. There are some privileged instructions that can only be
executed in kernel mode.
 These are interrupt instructions, input output management etc. If
the privileged instructions are executed in user mode, it is illegal
and a trap is generated.
Need of 2 mode
Need of 2 mode
 The lack of a dual mode i.e user mode and kernel
mode in an operating system can cause serious
problems. Some of these are:
 A running user program can accidentaly wipe out
the operating system by overwriting it with user data.
 Multiple processes can write in the same system at
the same time, with disastrous results.
Modes of Operation
Modes of Operation
Simple Batch System
Simple Batch System
Overhead
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. (How?)
 Processor is
often idle
 even with
automatic job
sequencing
 I/O devices
are slow
compared to
processor
 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
 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
 Multiprogramming
 also known as multitasking
 memory is expanded to hold three, four, or more programs
and switch among all of them
 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
computation
Table 2.3 Batch Multiprogramming versus Time Sharing
Layered Approach
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
Layered Operating System
Layered Operating System

An Overview of Operating Systems and algorithms.ppt

  • 1.
  • 2.
    Operating System Operating System A program that controls the execution of application programs  An interface between applications and hardware
  • 3.
    OS objectives OS objectives 1.Convenient: OS is used for user services like Program Execution, I/O operations, File System Manipulation, Communications and Error Detection to execute in a convenient manner.  2. Efficient: OS has the capability to provide an environment to run above user services in an efficient manner. Batch processing, Multiprocessing, multiprogramming, etc are some ways by which OS increases efficiency.  3. Ability to evolve: OS have the ability to evolve. Evolution has been as following- Batch Operating System, Time-sharing operating system, Distributed operating system, Network operating system, Real time operating system.
  • 4.
    The OS asa User/Computer Interface  Computer Hardware-Software Structure  Layered organization  OS services to users
  • 6.
    Operating System Services OperatingSystem Services  One set of operating-system services provides functions that are helpful to the user:  User interface - Almost all operating systems have a user interface (UI)  Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch  Program execution - The system must be able to load a program into memory and to run that program, end execution, either normally or abnormally (indicating error)  I/O operations - A running program may require I/O, which may involve a file or an I/O device.  File-system manipulation - The file system is of particular interest. Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management.
  • 7.
    Operating System Services OperatingSystem Services (Cont.) (Cont.)  One set of operating-system services provides functions that are helpful to the user (Cont):  Communications – Processes may exchange information, on the same computer or between computers over a network  Communications may be via shared memory or through message passing (packets moved by the OS)  Error detection – OS needs to be constantly aware of possible errors  May occur in the CPU and memory hardware, in I/O devices, in user program  For each type of error, OS should take the appropriate action to ensure correct and consistent computing  Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system
  • 8.
    Operating System Services OperatingSystem Services (Cont.) (Cont.)  Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing  Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them  Many types of resources - Some (such as CPU cycles,mainmemory, and file storage) may have special allocation code, others (such as I/O devices) may have general request and release code.  Accounting - To keep track of which users use how much and what kinds of computer resources  Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other  Protection involves ensuring that all access to system resources is controlled  Security of the system from outsiders requires user authentication, extends to defending external I/O devices from invalid access attempts  If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.
  • 9.
    A computer isa set of resources for moving, storing, & processing data The OS is responsible for managing these resources The OS exercises its control through software The Operating System as a Resource Manager
  • 10.
  • 11.
    OS as resourcemanager OS as resource manager  CPU: Perform execution of program – which is in high level language.Compiled or executable program has to be executed by CPUshould be brought into MM from disk.Because CPU can not directly access SS. It can access MM directly.  MM:Single memory block shared by multiple program of a user/users. DOS/UNIX. When CPU find piece of program or data on SS, it is duty of DD to bring it in MM.  I/O devices:I/P-keyboard-feed data , Printer/monitor-O/P.  Secondary storage-special I/O device.-File-R/W.  So OS responsibility to manage these devices efficiently. So more than 1 user can access those simultaneously.  Modern OS-Distributed computing- Avoid duplicates copy, efficient use of resources
  • 12.
    Evolution of Operating Evolutionof Operating Systems Systems  A major OS will evolve over time for a number of reasons:
  • 13.
    Evolution of Evolution of OperatingSystems Operating Systems  Stages include:
  • 14.
    Earliest Computers:  Nooperating 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 just on setting up the program to run
  • 16.
    Simple Batch Systems SimpleBatch 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
  • 17.
     Monitor controlsthe sequence of events  Resident Monitor is software always in memory  Monitor reads in job and gives control  Job returns control to monitor
  • 18.
    Job Control Language JobControl Language (JCL) (JCL)
  • 20.
    User and kernelmode User and kernel mode  User Mode :The system is in user mode when the operating system is running a user application such as handling a text editor. The transition from user mode to kernel mode occurs when the application requests the help of operating system or an interrupt or a system call occurs.  The mode bit is set to 1 in the user mode. It is changed from 1 to 0 when switching from user mode to kernel mode.  Kernel Mode:The system starts in kernel mode when it boots and after the operating system is loaded, it executes applications in user mode. There are some privileged instructions that can only be executed in kernel mode.  These are interrupt instructions, input output management etc. If the privileged instructions are executed in user mode, it is illegal and a trap is generated.
  • 22.
    Need of 2mode Need of 2 mode  The lack of a dual mode i.e user mode and kernel mode in an operating system can cause serious problems. Some of these are:  A running user program can accidentaly wipe out the operating system by overwriting it with user data.  Multiple processes can write in the same system at the same time, with disastrous results.
  • 23.
  • 26.
    Simple Batch System SimpleBatch System Overhead 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. (How?)
  • 27.
     Processor is oftenidle  even with automatic job sequencing  I/O devices are slow compared to processor
  • 28.
     The processorspends 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
  • 29.
     There mustbe 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
  • 30.
     Multiprogramming  alsoknown as multitasking  memory is expanded to hold three, four, or more programs and switch among all of them
  • 31.
     Can beused 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 computation
  • 32.
    Table 2.3 BatchMultiprogramming versus Time Sharing
  • 35.
    Layered Approach 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
  • 36.

Editor's Notes

  • #1 “Operating Systems: Internal and Design Principles”, 7/e, by William Stallings, Chapter 2 “Operating System Overview”.
  • #2 An OS is a program that controls the execution of application programs and acts as an interface between applications and the computer hardware. It can be thought of as having three objectives: • Convenience: An OS makes a computer more convenient to use. • Efficiency: An OS allows the computer system resources to be used in an efficient manner. • Ability to evolve: An OS should be constructed in such a way as to permit the effective development, testing, and introduction of new system functions without interfering with service.
  • #5 The Operating System as a User/Computer Interface The hardware and software used in providing applications to a user can be viewed in a layered or hierarchical fashion, as depicted in Figure 2.1 . The user of those applications, the end user, generally is not concerned with the details of computer hardware. Thus, the end user views a computer system in terms of a set of applications. An application can be expressed in a programming language and is developed by an application programmer. If one were to develop an application program as a set of machine instructions that is completely responsible for controlling the computer hardware, one would be faced with an overwhelmingly complex undertaking. To ease this chore, a set of system programs is provided. Some of these programs are referred to as utilities, or library programs. These implement frequently used functions that assist in program creation, the management of files, and the control of I/O devices. A programmer will make use of these facilities in developing an application, and the application, while it is running, will invoke the utilities to perform certain functions. The most important collection of system programs comprises the OS. The OS masks the details of the hardware from the programmer and provides the programmer with a convenient interface for using the system. It acts as mediator, making it easier for the programmer and for application programs to access and use those facilities and services.
  • #9 A computer is a set of resources for the movement, storage, and processing of data and for the control of these functions. The OS is responsible for managing these resources.
  • #10 Figure 2.2 suggests the main resources that are managed by the OS. A portion of the OS is in main memory. This includes the kernel , or nucleus , which contains the most frequently used functions in the OS and, at a given time, other portions of the OS currently in use. The remainder of main memory contains user programs and data. The memory management hardware in the processor and the OS jointly control the allocation of main memory, as we shall see. The OS decides when an I/O device can be used by a program in execution and controls access to and use of files. The processor itself is a resource, and the OS must determine how much processor time is to be devoted to the execution of a particular user program. In the case of a multiple-processor system, this decision must span all of the processors.
  • #12 A major OS will evolve over time for a number of reasons: • Hardware upgrades plus new types of hardware: For example, early versions of UNIX and the Macintosh OS did not employ a paging mechanism because they were run on processors without paging hardware. 1 Subsequent versions of these operating systems were modified to exploit paging capabilities. Also, the use of graphics terminals and page-mode terminals instead of line-at-a time scroll mode terminals affects OS design. For example, a graphics terminal typically allows the user to view several applications at the same time through “windows” on the screen. This requires more sophisticated support in the OS. • New services: In response to user demand or in response to the needs of system managers, the OS expands to offer new services. For example, if it is found to be difficult to maintain good performance for users with existing tools, new measurement and control tools may be added to the OS. • Fixes: Any OS has faults. These are discovered over the course of time and fixes are made. Of course, the fix may introduce new faults. The need to change an OS regularly places certain requirements on its design. An obvious statement is that the system should be modular in construction, with clearly defined interfaces between the modules, and that it should be well documented. For large programs, such as the typical contemporary OS, what might be referred to as straightforward modularization is inadequate [DENN80a]. That is, much more must be done than simply partitioning a program into modules. We return to this topic later in this chapter.
  • #13 In attempting to understand the key requirements for an OS and the significance of the major features of a contemporary OS, it is useful to consider how operating systems have evolved over the years.
  • #14 With the earliest computers, from the late 1940s to the mid-1950s, the programmer interacted directly with the computer hardware; there was no OS. These computers were run from a console consisting of display lights, toggle switches, some form of input device, and a printer. Programs in machine code were loaded via the input device (e.g., a card reader). If an error halted the program, the error condition was indicated by the lights. If the program proceeded to a normal completion, the output appeared on the printer. These early systems presented two main problems: • Scheduling : Most installations used a hardcopy sign-up sheet to reserve computer time. Typically, a user could sign up for a block of time in multiples of a half hour or so. A user might sign up for an hour and finish in 45 minutes; this would result in wasted computer processing time. On the other hand, the user might run into problems, not finish in the allotted time, and be forced to stop before resolving the problem. • Setup time: A single program, called a job , could involve loading the compiler plus the high-level language program (source program) into memory, saving the compiled program (object program) and then loading and linking together the object program and common functions. Each of these steps could involve mounting or dismounting tapes or setting up card decks. If an error occurred, the hapless user typically had to go back to the beginning of the setup sequence. Thus, a considerable amount of time was spent just in setting up the program to run. This mode of operation could be termed serial processing , reflecting the fact that users have access to the computer in series. Over time, various system software tools were developed to attempt to make serial processing more efficient. These include libraries of common functions, linkers, loaders, debuggers, and I/O driver routines that were available as common software for all users.
  • #16 Early computers were very expensive, and therefore it was important to maximize processor utilization. The wasted time due to scheduling and setup time was unacceptable. To improve utilization, the concept of a batch OS was developed. It appears that the first batch OS (and the first OS of any kind) was developed in the mid-1950s by General Motors for use on an IBM 701 [WEIZ81]. The concept was subsequently refined and implemented on the IBM 704 by a number of IBM customers. By the early 1960s, a number of vendors had developed batch operating systems for their computer systems. IBSYS, the IBM OS for the 7090/7094 computers, is particularly notable because of its widespread influence on other systems. The central idea behind the simple batch-processing scheme is the use of a piece of software known as the monitor . With this type of OS, the user no longer has direct access to the processor. Instead, the user submits the job on cards or tape to a computer operator, who batches the jobs together sequentially and places the entire batch on an input device, for use by the monitor. Each program is constructed to branch back to the monitor when it completes processing, at which point the monitor automatically begins loading the next program.
  • #17 Monitor point of view: The monitor controls the sequence of events. For this to be so, much of the monitor must always be in main memory and available for execution ( Figure 2.3 ). That portion is referred to as the resident monitor . The rest of the monitor consists of utilities and common functions that are loaded as subroutines to the user program at the beginning of any job that requires them. The monitor reads in jobs one at a time from the input device (typically a card reader or magnetic tape drive). As it is read in, the current job is placed in the user program area, and control is passed to this job. When the job is completed, it returns control to the monitor, which immediately reads in the next job. The results of each job are sent to an output device, such as a printer, for delivery to the user.
  • #18 The monitor performs a scheduling function: A batch of jobs is queued up, and jobs are executed as rapidly as possible, with no intervening idle time. The monitor improves job setup time as well. With each job, instructions are included in a primitive form of job control language (JCL) . This is a special type of programming language used to provide instructions to the monitor. A simple example is that of a user submitting a program written in the programming language FORTRAN plus some data to be used by the program. All FORTRAN instructions and data are on a separate punched card or a separate record on tape. In addition to FORTRAN and data lines, the job includes job control instructions, which are denoted by the beginning $.
  • #19 The monitor, or batch OS, is simply a computer program. It relies on the ability of the processor to fetch instructions from various portions of main memory to alternately seize and relinquish control. Certain other hardware features are also desirable: • Memory protection: While the user program is executing, it must not alter the memory area containing the monitor. If such an attempt is made, the processor hardware should detect an error and transfer control to the monitor. The monitor would then abort the job, print out an error message, and load in the next job. • Timer: A timer is used to prevent a single job from monopolizing the system. The timer is set at the beginning of each job. If the timer expires, the user program is stopped, and control returns to the monitor. • Privileged instructions : Certain machine level instructions are designated privileged and can be executed only by the monitor. If the processor encounters such an instruction while executing a user program, an error occurs causing control to be transferred to the monitor. Among the privileged instructions are I/O instructions, so that the monitor retains control of all I/O devices. This prevents, for example, a user program from accidentally reading job control instructions from the next job. If a user program wishes to perform I/O, it must request that the monitor perform the operation for it. Interrupts : Early computer models did not have this capability. This feature gives the OS more flexibility in relinquishing control to and regaining control from user programs.
  • #23 Considerations of memory protection and privileged instructions lead to the concept of modes of operation. A user program executes in a user mode , in which certain areas of memory are protected from the user’s use and in which certain instructions may not be executed. The monitor executes in a system mode, or what has come to be called kernel mode , in which privileged instructions may be executed and in which protected areas of memory may be accessed. Of course, an OS can be built without these features. But computer vendors quickly learned that the results were chaos, and so even relatively primitive batch operating systems were provided with these hardware features.
  • #26 With a batch OS, processor time alternates between execution of user programs and execution of the monitor. There have been two sacrifices: Some main memory is now given over to the monitor and some processor time is consumed by the monitor. Both of these are forms of overhead. Despite this overhead, the simple batch system improves utilization of the computer.
  • #27 Even with the automatic job sequencing provided by a simple batch OS, the processor is often idle. The problem is that I/O devices are slow compared to the processor. Figure 2.4 details a representative calculation. The calculation concerns a program that processes a file of records and performs, on average, 100 machine instructions per record. In this example, the computer spends over 96% of its time waiting for I/O devices to finish transferring data to and from the file.
  • #28 Figure 2.5a illustrates this situation, where we have a single program, referred to as 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.
  • #29 This inefficiency is not necessary. We know that there must be enough memory to hold the OS (resident monitor) and one user program. Suppose that there is room for the OS and two user programs. 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 ( Figure 2.5b ).
  • #30 Furthermore, we might expand memory to hold three, four, or more programs and switch among all of them ( Figure 2.5c ). The approach is known as multiprogramming , or multitasking . It is the central theme of modern operating systems.
  • #31 Just as multiprogramming allows the processor to handle multiple batch jobs at a time, multiprogramming can also be used to handle multiple interactive jobs. In this latter case, the technique is referred to as time sharing , because processor time is shared among multiple users. In a time-sharing system, 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 computation. Thus, if there are n users actively requesting service at one time, each user will only see on the average 1/ n of the effective computer capacity, not counting OS overhead. However, given the relatively slow human reaction time, the response time on a properly designed system should be similar to that on a dedicated computer.
  • #32 Both batch processing and time sharing use multiprogramming. The key differences are listed in Table 2.3 .