chapter_2 os

59
CHAPTER 2 OPERATING SYSTEM OVERVIEW 1

description

os note chpt2

Transcript of chapter_2 os

C H A P T E R 2

OPERATING SYSTEM OVERVIEW

1

Objectives

2

Describe the key function of an operating system (OS).

Discuss the evolution of OS from early simple batch system to modern complex system

Explain each of the major achievements in OS

Discuss the key design areas in the development of modern OS

Topics 3

OS definition, objectives and functions

Evolution of the OS

Major achievements

Development leading to modern OS

Definition of an Operating System (OS)

4

A program that controls the execution of application programs

An interface between applications and hardware

Objectives of an OS

5

1. Convenience

Makes the computer more convenient to use

2. Efficiency

Allows computer system resources to be used in an efficient manner

3. Ability to Evolve

Permits effective development, testing, and introduction of new system functions without interfering with service

Obj 1: As a User/Computer Interface

6

Hardware and software used in providing applications to a user can be viewed in a layered or hierarchical fashion as shown in figure below:

A set of system programs in assisting program creation, management of files and controlling I/O. Application running and will call this utilities to perform function.

Obj 1: As a User/Computer Interface…

7

Utilities: A set of system programs in assisting program creation, management

of files and controlling I/O Application running and will call this utilities to perform function

OS in 3rd layer masks the details of hardware from the programmer with a convenient interface for using the system. most important system programs are here

OS act as a mediator, making it easier for the programmer and for application programs to access and use those facilities and services.

Obj 1: As a User/Computer Interface…

8

OS provides services in the following areas: Program development

Provides editors and debuggers to assist programmer in developing programs

Program execution

Number of tasks need to be performed in executing a program

OS handle the scheduling duties for the user

Access to I/O devices

Provides a uniform interface that hides the details so programmer can access devices using simple read and writes.

Controlled access to files

Protection mechanism to control access to files

Obj 1: As a User/Computer Interface…

9

System access In shared or public system, OS control access to the system

Error detection and response Errors occur while computer run:

Internal and external hardware errors

Software errors

OS cannot grant request of application

OS provide response that clear the error condition with least impact to running applications

Ending program that cause error

Retrying the operation

Reporting error to application

Obj 1: As a User/Computer Interface

10

Accounting

collect statistics

monitor performance

used to anticipate future enhancements

used for billing users

Obj 2: As Resource Manager

11

A computer is a set of resources for the movement, storage and processing of data and for the control of these functions.

OS is responsible for managing the resources.

OS functions same way as ordinary computer software It is a program that is executed

The differences are OS directs the processor in the use of the other system resources and in the timing of its execution of other programs

Obj 2: As Resource Manager…

12

Operating system gives control to the processor to execute programs and then take back control to prepare the processor to execute the next piece of work.

Figure 2.2 shows the main resources that are managed by the operating system.

A portion of the OS is stored in main memory.

This include the kernel or nucleus which contains the most frequently used functions in the OS and other portions of OS that are currently in use.

13

Obj 3: Ease of Evolution of an OS

14

Major OS will evolve over the time because:

Hardware upgrades and new types of hardware

New services

Fix any fault

Evolution of Operating Systems

15

Serial Processing

Simple Batch System

Multiprogramming Batch System

Time Sharing System

Serial Processing

16

No operating system

User interact directly with computer hardware.

Machines run from a console with display lights and toggle switches, input device, and printer

Mode of operation could be termed serial processing because users have access to the computer in series.

Serial Processing… 17

How it works?

Programs in machine code were loaded via the input device (e.g.. Card Reader)

If there is an error (indicated by the lights) halt the program.

Then the programmer will proceed to examine processor registers and main memory to determine the cause of error.

If the program proceeds to normal completion, the output will be printed.

Serial Processing…

18

• Scheduling • Setup time

Two Problems

processor idle most of the time Doing nothing, waiting to execute a job

4

Serial Processing…

19

Scheduling

How user “use” the machine

User reserves machine time

Used a hardcopy sign-up sheet

Problem arise when user sign up more than the time needed or can’t complete their job within the time reserve.

Reserved for 1 hour, but completed job for 20 minutes 40 minutes is a processor idle time

Reserved for 1 hour, but job did not complete because of error occurs need to reserve another time

Serial Processing…

20

Setup time

Many steps involve in running a single program/job

load the compiler + source program to memory

saving the compiled program

load and link the object program and common functions

each of these steps involving mounting or dismounting tapes

If error occurred, user had to go back to the beginning setup step.

Much of the time is spent on setting up program.

Serial Processing…

21

Over the time, various system software tools were developed to attempt to make serial processing more efficient.

Libraries of common functions, linkers, loaders, debuggers and I/O driver routines.

Simple Batch Systems

22

Early machine was so expensive so it is important to maximize machine utilization minimize the idle time of the processor.

To improve utilization, the concept of a batch OS was developed.

The use of software known as the monitor.

With monitor user have no longer direct access to the machine.

Simple Batch Systems…

23

Monitors:

Software that controls the running programs

Batch jobs together

Program branches back to monitor when finished

A part of the monitor call “Resident monitor” is in main memory and available for execution

24

Simple Batch Systems…

25

How monitor works: Monitor reads jobs one at a time from the input device Monitor places a job in the user program area A monitor instruction branches to the start of the user program Execution of user program continues until

End of program occurs Error occurs

This will cause the CPU to fetch its next instruction from monitor.

With each job, instructions are included in a primitive form of job control language (JCL) Special type of programming language used to provides instruction

to the monitor what compiler to use what data to use

Simple Batch Systems…

26

Example of job format using FORTRAN language:

$JOB $FTN … FORTRAN Program … $LOAD $RUN … DATA … $END

Instruction starts with a $ is a JCL language

With JCL: • Each read instruction (in user

program) causes one line of input to be read

• Causes input routine (OS) to be invoke Checks for not reading JCL line Skip to the next JCL line at

completion of user program

5

Simple Batch Systems… How monitor works:

Monitor reads jobs one at a time from the input device

Monitor places a job in the user program area A monitor instruction branches to the start of

the user program Execution of user program continues until

End of program occurs Error occurs

This will cause the CPU to fetch its next instruction from monitor.

With each job, instructions are included in a primitive form of job control language (JCL) Special type of programming language used to

provides instruction to the monitor what compiler to use

what data to use

25

Simple Batch Systems… Example of job format using FORTRAN

language:

$JOB $FTN

… FORTRAN Program

… $LOAD $RUN

… DATA

… $END

Instruction start with a $ is a JCL language With JCL:

•Each read instruction (in user program) causes one line of input to be read

•Causes input routine (OS) to be invoke Checks for not reading JCL line

Skip to the next JCL line at completion of user program

26

Simple Batch Systems…

27

With JCL:

Each read instruction (in user program) causes one line of input to be read

Causes input routine (OS) to be invoked

Checks for not reading JCL line

Skip to the next JCL line at completion of user program

Simple Batch Systems…

28

In summary, the monitor or batch OS:

It is a computer program

Relies on the

ability of the processor to fetch instructions from the various portions of the main memory to alternately seize and relinquish control.

available hardware to effectively alternate execution from various parts of memory

Simple Batch Systems…

29

Desirable hardware features for batch OS: Memory protection

Do not allow the memory area containing the monitor to be altered by users programs.

If it happens, processor should detect an error and transfer control to the monitor.

Monitor will abort the job, print out error message and load the next job.

Timer

Prevents a job from monopolizing the system.

Timer is set at the beginning of each job.

An interrupt occurs when time is expired.

Simple Batch Systems…

30

Privileged instruction

Can be executed only by the monitor

An interrupt occurs if a program tries these instructions.

E.g. I/O instructions.

Interrupts

Provides flexibility for relinquishing control to and regaining control from user programs

Multi-programmed Batch System

31

Simple Batch OS implement uniprogramming technique

Uniprogramming:

Processor execute a job, when job need for I/O, processor must wait for I/O instruction to complete before proceed execute the same job

Multi-programmed Batch System…

32

Multiprogramming:

Processor execute a job, When job needs to wait for I/O, the processor can switch to the other job

33

34

35

Example: JOB1 JOB2 JOB3 Type of job Heavy compute Heavy I/O Heavy I/O Duration 5 min. 15 min. 10 min. Memory required 50K 100 K 80 K Need disk? No No Yes Need terminal? No Yes No Need printer? No No Yes

36

Effects of multiprogramming: Uniprogramming Multiprogramming Processor use 22% 43% Memory use 30% 67% Disk use 33% 67% Printer use 33% 67% Elapsed time 30 min. 15 min. Throughput rate 6 jobs/hr 12 jobs/hr Mean response time 18 min. 10 min.

Time Sharing

37

A need to provide a mode in which the user interacts directly with the computer

Transaction processing

Batch multiprogramming does not support interactions with users

Time sharing extends multiprogramming to handle multiple interactive jobs.

It is called time sharing because the processor’s time is shared among multiple users.

38

Evolution of Operating Systems…

39

Both batch OS and time sharing implement multiprogramming.

The differences between batch OS and time sharing is shown below:

Batch

Multiprogramming Time Sharing

Principal objective

Maximize processor use

Minimize response time

Source of directives to operating system

Job control language commands provided with the job

Commands entered at the terminal

Major Achievements

40

OS is the most complex pieces of software ever developed.

Five major theoretical advances in the development of OS:

Process

Memory Management

Information protection and security

Scheduling and resource management

System structure

Process

41

Introduced to obtain a systematic way of monitoring and controlling program execution.

Definitions of process:

A program in execution

An instance of a program running on a computer

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

Process…

42

Three major lines of computer system development created problems in timing and synchronization that contributed to the development: Multiprogramming batch operation

processor is switched among the various programs residing in main memory

Time sharing

be responsive to the individual user but be able to support many users simultaneously

Real-time transaction

a number of users are entering queries or updates against a database

Process…

43

Difficulties with Designing System Software

Improper synchronization a program must wait until the data are available in a buffer improper design of the signalling 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 only one routine at time allowed to perform an update against the file

Nondeterminate program operation program execution is interleaved by the processor when memory is shared the order in which programs are scheduled may affect their outcome

Deadlocks it is possible for two or more programs to be hung up waiting for each other may depend on the chance timing of resource allocation and release

Process…

44

A component of a process:

An executable program

Associated data needed by the program

Execution context of the program

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

45

Memory Management

46

Five principle storage management responsibilities:

Process isolation

Automatic allocation and management

Support for modular programming

Protection and access control

Long-term storage

The key contribution is virtual memory and file system facilities.

Information Protection and Security

47

Protection of information is needed since the growth in

the use of time-sharing systems and computer network. Work in security and protection as it relates to OS can be

roughly grouped into four categories. Availability

Protecting the system against interruption

Confidentiality Assures that user cannot read data for which access is unauthorized

Data Integrity Protection of data from unauthorized modification

Authenticity Proper verification of identity of users and the validity of messages or

data

Scheduling and Resource Management

48

Main task of the OS is to manage the various resources available and to schedule their use by the active process.

Resource allocation and scheduling policy must consider three factors: Fairness

give equal and fair access to all processes

Differential responsiveness

discriminate between different classes of jobs

Efficiency

maximize throughput, minimize response time, and accommodate as many uses as possible

System Structure

49

Because of it’s enormous complexity, the OS can be viewed as a series of levels

Each level performs a related subset of functions

Each level relies on the next lower level to perform more primitive functions

Well defined interfaces: one level can be modified without affecting other levels

This decomposes a problem into a number of more manageable sub problems

50

51

Developments Leading to Modern OS

52

New design elements for OS were introduced recently that

create a major change in the nature of OS. Why? In response to

New hardware developments multiprocessor systems high-speed networks faster processors and larger memory

New Applications multimedia applications Internet and Web access Client/Server applications

New Security Threats Viruses, worms Hacking techniques

Developments Leading to Modern OS…

53

Changes not only in modification and enhancement to existing architectures but also in new ways of organizing the operating system.

Much of the works fits into:

1) Microkernel architecture

2) Multithreading

3) Symmetric multiprocessing

4) Distributed OS

5) Object-oriented design.

Microkernel Architecture

54

Only a few essential functions in the kernel

primitive memory management (address space)

Inter-process communication (IPC)

basic scheduling

Other OS services are provided by processes running in user mode (servers)

Such as device drivers, file system, virtual memory

Provide more flexibility, extensibility, portability

Multithreading

55

A process is a collection of one or more threads that can run simultaneously

Useful when the application consists of several tasks that do not need to be serialized E.g. database server that listens for and processes numerous client

requests

Gives the programmer a greater control over the timing of application-related events

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 these with processes.

Symmetric Multiprocessing

56

Refers to a computer hardware architecture and also to the operating system behaviour that reflects that architecture.

Standalone computer system with the following characteristics: A computer with multiple processors

These processors share the same main memory and I/O facilities, interconnected by a communication bus or other internal connection scheme.

All processor can perform the same functions

Existence of multiple processors is transparent to the user.

Symmetric Multiprocessing…

57

Advantages over uniprocessor architecture:

1) Performance

2) Availability

3) Incremental Growth

4) Scaling

Distributed OS

58

Distributed OS is a collection of independent computers that appears to the users of the system as a single computer.

Provides the illusion of a single main memory and single secondary memory space, i.e. appearing as a single system to the user.

E.g.. Cluster computer.

Object Oriented Design

59

Used for adding modular extensions to a small kernel

At the OS levels an object-based structure enables programmers to customize an operating system without disrupting system integrity

Eases the development of distributed tools and full-blown of distributed OS.