64
18 September 2008 CIS 340 # 1 Operating System Control program for the execution of application programs An interface between applications and hardware An intermediary between a user of a computer and the computer hardware

Operating System

  • Upload
    rigg

  • View
    47

  • Download
    0

Embed Size (px)

DESCRIPTION

Operating System. Control program for the execution of application programs An interface between applications and hardware An intermediary between a user of a computer and the computer hardware. Operating System Objectives. Convenience Makes the computer more convenient to use - PowerPoint PPT Presentation

Citation preview

Page 1: Operating System

18 September 2008 CIS 340# 1

Operating System• Control program for the

execution of application programs

• An interface between applications and hardware

• An intermediary between a user of a computer and the computer hardware

Page 2: Operating System

# 2

Operating System Objectives• Convenience

– Makes the computer more convenient to use• Efficiency

– Allows computer system resources to be used in an efficient manner

• Ability to evolve– Permit effective development, testing, and

introduction of new system functions without interfering with service

Page 3: Operating System

18 September 2008 CIS 340# 3

Layers of Computer System

Page 4: Operating System

# 4

Services Provided by the Operating System• Program development

– Editors and debuggers• Program execution• Access to I/O devices• Controlled access to files• System access

Page 5: Operating System

# 5

Services Provided by the Operating System• Error detection and response

– Internal and external hardware errors• Memory error• Device failure

– Software errors• Arithmetic overflow• Access forbidden memory locations

– Operating system cannot grant request of application

Page 6: Operating System

# 6

Services Provided by the Operating System• Accounting

– Collect usage statistics– Monitor performance– Used to anticipate future enhancements– Used for billing purposes

Page 7: Operating System

18 September 2008 CIS 340# 7

Operating System: Other Services• Allows multiple, concurrent computations

– Allows through enabling resources allocation• Controls interactions between concurrent

computations– Enforces rules to securely execute the

computations without losing integrity• Supports interactions of computations

among different computer systems– Handles networking interactions

Page 8: Operating System

18 September 2008 CIS 340# 8

Operating System Definitions

Resource allocator – Manages and allocates resources

Control program – Controls the execution of user programs– Controls operations of I/O devices

Kernel – Portion of operating system running at all times in main memory– All and anything else being application programs– Contains most frequently used functions– Also called the nucleus

Page 9: Operating System

9

Page 10: Operating System

18 September 2008 CIS 340# 10

Migration of OS Concepts and Features through Platforms

Batch

TIME SHARE

Page 11: Operating System

18 September 2008 CIS 340# 11

Computer-System Architecture

1. Control Unit

2. Arithmetic / Logic Unit

3. Memory

Page 12: Operating System

18 September 2008 CIS 340# 12

Hardware FeaturesHW realization supporting OS services

• Memory protection– Do not allow the memory area containing the

monitor to be altered– User program executes in user mode

• Certain instructions may not be executed– Monitor executes in system mode

• Kernel mode• Privileged instructions are executed• Protected areas of memory may be

accessed

Page 13: Operating System

18 September 2008 CIS 340# 13

Hardware FeaturesHW realization supporting OS services

• Timer– Prevents a job from monopolizing the system

• Privileged instructions– Certain machine level instructions to be

executed only by the monitor• Interrupts

– Early computer models did not have this capability

Page 14: Operating System

18 September 2008 CIS 340# 14

Computer-System Operation: Premises• I/O devices and the CPU can execute

concurrently• Each device controller handles a

particular device type• Each device controller has a local buffer• CPU moves data from/to main memory

to/from local buffers• I/O is from the device to local buffer of

controller• Interrupt generated by device controller

informs CPU about end of controller’s task

Page 15: Operating System

18 September 2008 CIS 340# 15

Interrupts: Expectations• Transfers control to the interrupt service

routine • Interrupt vector contains the addresses of all

the service routines• Interrupt architecture saves the address of the

interrupted instruction• A trap is a software-generated interrupt

caused either by an error or a user request.• An operating system is interrupt driven

Def:

Page 16: Operating System

Interrupt service routine (ISR)• An interrupt handler,

– also known as an interrupt service routine (ISR), – is a callback subroutine in an operating system or 

device driver – whose execution is triggered by the reception of an interrupt.– have a multitude of functions, which vary based on the

reason the interrupt was generated and the speed at which the interrupt handler completes its task.

• An interrupt handler is a low-level counterpart of event handlers. – These handlers are initiated by either hardware interrupts or

interrupt instructions in software, – used for servicing hardware devices and transitions between

protected modes of operation such as system calls.

18 September 2008 CIS 340# 16

Page 17: Operating System

Interrupt vector• In computing, an interrupt vector is

– the memory address of an interrupt handler, – or an index into an array called an

interrupt vector table or dispatch table containing the memory addresses of interrupt handlers.

• When an interrupt is generated,– the processor saves its execution state via a 

context switch, and– begins execution of the interrupt handler at the

interrupt vector.

18 September 2008 CIS 340# 17

Page 18: Operating System

18 September 2008 CIS 340# 18

I/O Devices Sloooooooooooow

EX: System Utilization:

Page 19: Operating System

18 September 2008 CIS 340# 19

EX: UniprogrammingProcessor must

wait for I/O instruction to

complete before preceding

Processor must wait for I/O

instruction to complete before

preceding

Page 20: Operating System

18 September 2008 CIS 340# 20

EX: Multiprogrammingwith Three Programs

Processor experiences less

lapses

Page 21: Operating System

18 September 2008 CIS 340# 21

CONSIDER: Utilization Histograms

Page 22: Operating System

18 September 2008 CIS 340# 22

EX: Sample Program Execution Attributes

Page 23: Operating System

18 September 2008 CIS 340# 23

EX: Typical I/O Rates for Devices

Page 24: Operating System

# 24

Process• Consists of three components

–An executable program–Associated data needed by the

program–Execution context of the program

• All information the operating system needs to manage the process

Page 25: Operating System

# 25

Process

Page 26: Operating System

# 26

Memory Management• Process isolation• Automatic allocation and management• Support of modular programming• Protection and access control• Long-term storage

Page 27: Operating System

# 27

Virtual Memory• Allows programmers to address

memory from a logical point of view• No hiatus between the execution of

successive processes while one process was written out to secondary store and the successor proceess was read in

Page 28: Operating System

# 28

Virtual Memory and File System• Implements long-term store• Information stored in named objects

called files

Page 29: Operating System

# 29

Paging• Allows process to be comprised of a

number of fixed-size blocks, called pages

• Virtual address is a page number and an offset within the page

• Each page may be located any where in main memory

• Real address or physical address in main memory

Page 30: Operating System

# 30

Virtual Memory

Page 31: Operating System

# 31

Virtual Memory Addressing

Page 32: Operating System

18 September 2008 CIS 340# 32

Page 33: Operating System

18 September 2008 CIS 340# 33

OS Key Elements

Page 34: Operating System

18 September 2008 CIS 340# 34

Problems Arising with System Software

1. Improper synchronization– Ensure a process waiting for an

I/O device receives the signal2. Failed mutual exclusion

– Memory overwrites3. Nondeterminate program operation

– Program A should only depend on input to it

– Activities of other programs should not influence Program A’s outcome

4. Deadlocks

Page 35: Operating System

18 September 2008 CIS 340# 35

System Structure• 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

LEVELS(1-4) Process Hardware Levels

(5-7) Concepts with Multiprogramming (8-13) Deal with External Objects

Page 36: Operating System

18 September 2008 CIS 340# 36

Process Hardware Levels

• Level 1– Electronic circuits– Objects are registers, memory cells, and logic

gates– Operations are clearing a register or reading a

memory location

• Level 2– Processor’s instruction set– Operations such as add, subtract, load, and store

• Level 3– Adds the concept of a procedure or subroutine,

plus call/return operations

• Level 4– Interrupts

Page 37: Operating System

18 September 2008 CIS 340# 37

Concepts with Multiprogramming• Level 5

– Process as a program in execution– Suspend and resume processes

• Level 6– Secondary storage devices– Transfer of blocks of data

• Level 7– Creates logical address space for

processes– Organizes virtual address space

into blocks

Page 38: Operating System

18 September 2008 CIS 340# 38

Deal with External Objects (p 1 / 2)

• Level 8– Communication of information and

messages between processes• Level 9

– Supports long-term storage of named files

• Level 10– Provides access to external

devices using standardized interfaces

Page 39: Operating System

18 September 2008 CIS 340# 39

Deal with External Objects (p 2 / 2)

• Level 11– Maintains the association

between the external and internal identifiers

• Level 12– Provides full-featured facility for

the support of processes• Level 13

– Provides an interface to the operating system for the user

Page 40: Operating System

18 September 2008 CIS 340# 40

Modern Operating Systems: Concepts

• Microkernel architecture• Multithreading• Symmetric multiprocessing

(SMP)

Page 41: Operating System

# 41

Modern Operating Systems• Distributed operating systems

–Provides the illusion of a single main memory space and single secondary memory space

Page 42: Operating System

# 42

Modern Operating Systems• Object-oriented design

–Used for adding modular extensions to a small kernel

–Enables programmers to customize an operating system without disrupting system integrity

Page 43: Operating System

# 43

Windows Architecture• Modular structure for flexibility• Executes on a variety of hardware

platforms• Supports application written for other

operating system

Page 44: Operating System

44

Page 45: Operating System

# 45

Operating System Organization• Modified microkernel architecture

– Not a pure microkernel – Many system functions outside of the

microkernel run in kernel mode• Any module can be removed, upgraded, or

replaced without rewriting the entire system

Page 46: Operating System

# 46

Kernel-Mode Components• Executive

– Contains base operating system services• Memory management• Process and thread management• Security• I/O• Interprocess communication

• Kernel– Consists of the most used components

Page 47: Operating System

# 47

Kernel-Mode Components• Hardware abstraction layer (HAL)

– Isolates the operating system from platform-specific hardware differences

• Device drivers– Translate user I/O function calls into specific

hardware device I/O requests• Windowing and graphics systems

– Implements the graphical user interface (GUI)

Page 48: Operating System

# 48

Windows Executive• I/O manager• Cache manager• Object manager• Plug and play manager• Power manager• Security reference monitor• Virtual memory manager• Process/thread manager• Configuration manager• Local procedure call (LPC) facility

Page 49: Operating System

# 49

User-Mode Processes• Special system support processes

–Ex: logon process and the session manager

• Service processes• Environment subsystems• User applications

Page 50: Operating System

# 50

Client/Server Model• Simplifies the Executive

– Possible to construct a variety of APIs• Improves reliability

– Each service runs on a separate process with its own partition of memory

– Clients cannot not directly access hardware• Provides a uniform means for applications to

communicate via LPC• Provides base for distributed computing

Page 51: Operating System

# 51

Threads and SMP• Operating system routines can run on any

available processor• Different routines can execute

simultaneously on different processors• Multiple threads of execution within a single

process may execute on different processors simultaneously

• Server processes may use multiple threads• Share data and resources between process

Page 52: Operating System

# 52

Windows Objects• Encapsulation

– Object consists of one or more data items and one or more procedures

• Object class or instance– Create specified instances of an object

• Inheritance– Support to some extent in the Executive

• Polymorphism

Page 53: Operating System

# 53

UNIX• Hardware is surrounded by the

operating system software• Operating system is called the system

kernel• Comes with a number of user services

and interfaces–Shell–Components of the C compiler

Page 54: Operating System

# 54

UNIX

Page 55: Operating System

System call• Is how a program requests a service from an operating system's 

kernel that it does not normally have permission to run. • Provide the interface between a process and the operating system. • Most operations interacting with the system require permissions not

available to a user level process requires the use of system calls.– e.g. I/O performed with a device present on the system, – or any form of communication with other processes

• On Unix, Unix-like and other POSIX-compatible operating systems, popular system calls – open, read, write, close,wait, execve, fork, exit, and kill.

• Many of today's operating systems have hundreds of system calls. – For example,Linux has over 300 different calls, FreeBSD has

over 500[1], while Plan 9 has 51.

18 September 2008 CIS 340# 55

Page 56: Operating System

System calls 5 categories• Process Control.

– load– execute– create process– terminate process– get/set process attributes– wait for time, wait event, 

signal event– allocate, free memory

• File management.– create file, delete file– open, close– read, write, reposition– get/set file attributes

• Device Management.– request device, release device– read, write, reposition– get/set device attributes– logically attach or detach devices

• Information Maintenance.– get/set time or date– get/set system data– get/set process, file, or device

attributes• Communication.

– create, delete communication connection

– send, receive messages– transfer status information– attach or detach remote devices

18 September 2008 CIS 340# 56

Page 57: Operating System

# 57

UNIX Kernel

Page 58: Operating System

# 58

Modern UNIX Kernel

Page 59: Operating System

# 59

Modern UNIX Systems• System V Release 4 (SVR4)• Solaris 9• 4.4BSD• Linux

Page 60: Operating System
Page 61: Operating System

18 September 2008 CIS 340# 61

Transactional Properties:

ACID Test

A tomicity: If several components must come together for a process, then each

atomic process operates correctly or entire combination

abortsC onsistency:

A service is correct when executed in its entirety and false

or incorrect data is not introduced into the component

databasesI solation:

If several clients request the same service at the same time and access the same data, the

overall result will be as if they were alone – isolated -- in the

systemD urability:

Completed transactions are complete and durable (have duration?)

If necessary, redoing and undoing of changes in case of failures can

occur

TP-Monitor

transactional coordination

CLIENT

services

Application 1 Application 3Application 2

user program

CLIENT

SERVER

Page 62: Operating System

18 September 2008 CIS 340# 62

Simple Batch Systems“Monitors”

• Software • Controlled sequence of events• Program branches back to monitor when

finished

Job Control Language (JCL)• Special type of programming language• Provides instruction to the monitor

– What compiler to use?– What data to use?

Page 63: Operating System

18 September 2008 CIS 340# 63

Time Sharing• Uses multiprogramming to handle

multiple interactive jobs• Processor’s time is shared among

multiple users• Multiple users simultaneously access

the system through terminals

Page 64: Operating System

18 September 2008 CIS 340# 64

EX: Multiprogramming and Multiprocessing