76
Operating System Concepts Silberschatz and Galvin 1999 1.1 Workshop 1: Agenda Introductions and discussion on course overview Formation of study groups. Discussion on the study group project. Lecture and discussion on computer architecture evolution Group activity on development of operating systems (1/2 hr) Break Lecture and discussion on components of a computer system. Group activity on common classes of system services. (1/2 hr) Workshop summary and preview of the next workshop.

Silberschatz and Galvin 1999 1.1 Operating System Concepts Workshop 1: Agenda Introductions and discussion on course overview Formation of study groups

Embed Size (px)

Citation preview

Operating System Concepts Silberschatz and Galvin 1999 1.1

Workshop 1: Agenda

• Introductions and discussion on course overview

• Formation of study groups.

• Discussion on the study group project.

• Lecture and discussion on computer architecture evolution

• Group activity on development of operating systems (1/2 hr)

• Break

• Lecture and discussion on components of a computer system.

• Group activity on common classes of system services. (1/2 hr)

• Workshop summary and preview of the next workshop.

Operating System Concepts Silberschatz and Galvin 1999 1.2

CSS/420 Topics

• Computer Components and Operation

• Process management

• Concurrency

• Memory Management

• File Systems

• Input/Output

• Distributed Systems & Networking

• Security

• Examples (Unix, Linux, Windows NT)

Operating System Concepts Silberschatz and Galvin 1999 1.3

CSS/420 Schedule

• Workshop 1: Introduction, O/S Evolution, Components

• Workshop 2: Processes and resource allocation

– Homework

– Study group paper & presentations

• Workshop 3: Memory management

– Homework

– Study group paper & presentations

• Workshop 4: File systems

– Homework

– Study group paper only - no presentation!

– Exam # 1 (1 hr): ch’s 1-11

Operating System Concepts Silberschatz and Galvin 1999 1.4

CSS/420 Schedule (cont’d)

• Workshop 5: Input/Output– Homework: ch’s 12-14– Study group paper & presentation

• Workshop 6: Distributed systems & networks– Homework: ch’s 15-18– Study group paper & presentation

• Workshop 7: Security– Homework: ch’s 19, 20– Study group paper & presentation

• Workshop 8: Final– Study group final paper– Study group final presentation– Exam #2: ch’s 12-20

Operating System Concepts Silberschatz and Galvin 1999 1.5

CSS/420 Study Group Project

• Select an O/S (DOS, Linux, Unix, Windows NT, etc.)

• Brief presentation weeks 2, 3, 5, 6, 7

• Paper all weeks 2-7

• Workshop2: Processes, Scheduling

• Workshop 3: Memory Management

• Workshop 4: File Systems

• Workshop 5: Input/Output

• Workshop 6: Distributed Systems

• Workshop 7: Security

• Workshop 8: Final Paper and Oral Presentation

Operating System Concepts Silberschatz and Galvin 1999 1.6

Study Group Project (cont’d)

• Final presentation

– All study group members

– ½ hour

– Visuals (demo if desired)

• Final paper

– 12-15 pages (formed from interim papers)

– APA format

– Table of contents

– Introduction, Body, Conclusion

– References

– Spell, grammar checked

Operating System Concepts Silberschatz and Galvin 1999 1.7

Study Group Project (Cont’d)

• Topics

– Processes & concurrency

– Main & secondary storage management

– File system

– I/O control

– Distributed structures (lite)

– Security

Operating System Concepts Silberschatz and Galvin 1999 1.8

Module 1: Introduction to O/S’s

• What is an operating system?

• Simple Batch Systems

• Multiprogramming Batch Systems

• Time-Sharing Systems

• Personal-Computer Systems

• Parallel Systems

• Distributed Systems

• Real -Time Systems

Operating System Concepts Silberschatz and Galvin 1999 1.9

What is an Operating System?

• A program that acts as an intermediary between a user of a computer and the computer hardware.

• Operating system goals:

– Execute user programs and make solving user problems easier.

– Make the computer system convenient to use.

• Use the computer hardware in an efficient manner.

Operating System Concepts Silberschatz and Galvin 1999 1.10

Computer System Components

1. Hardware – provides basic computing resources (CPU, memory, I/O devices).

2. Operating system – controls and coordinates the use of the hardware among the various application programs for the various users.

3. Applications programs – define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs).

4. Users (people, machines, other computers).

Operating System Concepts Silberschatz and Galvin 1999 1.11

Abstract View of System Components

Operating System Concepts Silberschatz and Galvin 1999 1.12

Operating System Definitions

• Resource allocator – manages and allocates resources.

• Control program – controls the execution of user programs and operations of I/O devices .

• Kernel – the one program running at all times (all else being application programs).

Operating System Concepts Silberschatz and Galvin 1999 1.13

Simple Batch Systems

• Hire an operator

• User operator

• Add a card reader

• Reduce setup time by batching similar jobs

• Automatic job sequencing – automatically transfers control from one job to another. First rudimentary operating system.

• Resident monitor

– initial control in monitor

– control transfers to job

– when job completes control transfers pack to monitor

Operating System Concepts Silberschatz and Galvin 1999 1.14

Memory Layout for a Simple Batch System

Operating System Concepts Silberschatz and Galvin 1999 1.15

Control Cards

• Problems

1. How does the monitor know about the nature of the job (e.g., Fortran versus Assembly) or which program to execute?

2. How does the monitor distinguish (a) job from job?(b) data from program?

• Solution

– Introduce control cards

– Special character in column 1

– Ex’s: $FTN, $JOB, $RUN

Operating System Concepts Silberschatz and Galvin 1999 1.16

Spooling

• Overlap I/O of one job with computation of another job. While executing one job, the OS.

– Reads next job from card reader into a storage area on the disk (job queue).

– Outputs printout of previous job from disk to printer.

• Job pool(queue) – data structure that allows the OS to select which job to run next in order to increase CPU utilization. Basis for short-term and long-term scheduling data structures.

Operating System Concepts Silberschatz and Galvin 1999 1.17

Multiprogrammed Batch Systems

Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them.

Operating System Concepts Silberschatz and Galvin 1999 1.18

OS Features Needed for Multiprogramming

• I/O routine supplied by the system.

• Memory management – the system must allocate the memory to several jobs.

• CPU scheduling – the system must choose among several jobs ready to run.

• Allocation of devices.

• Key performance measure is throughput and turn-around time.

Operating System Concepts Silberschatz and Galvin 1999 1.19

Time-Sharing Systems–Interactive Computing

• The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory).

• A job swapped in and out of memory to the disk.

• On-line communication between the user and the system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” not from a card reader, but rather from the user’s keyboard.

• On-line system must be available for users to access data and code.

• Key performance measure is response time.

Operating System Concepts Silberschatz and Galvin 1999 1.20

Personal-Computer Systems

• Personal computers – computer system dedicated to a single user.

• I/O devices – keyboards, mice, monitors, printers, CD-ROM’s.

• User convenience and responsiveness.

• Can adopt technology developed for larger operating system; often individuals have sole use of computer and do not need advanced CPU utilization or protection features.

• Commonly have graphics intensive user interfaces

• Modern PC’s have a very sophisticated hardware architecture designed to support both multi-tasking and graphics.

Operating System Concepts Silberschatz and Galvin 1999 1.21

Migration of Operating-System Concepts and Features

Operating System Concepts Silberschatz and Galvin 1999 1.22

Parallel Systems

• Multiprocessor systems with more than on CPU in close communication.

• Tightly coupled system – processors share memory and a clock; communication usually takes place through the shared memory.

• Advantages of parallel system: – Increased throughput– Economical – Increased reliability

graceful degradation fail-soft systems

• Types of parallel systems:– Symmetric– Asymmetric

Operating System Concepts Silberschatz and Galvin 1999 1.23

Real-Time Systems

• Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems.

• Well-defined fixed-time constraints.

• Hard real-time system.

– Secondary storage limited or absent, data stored in short-term memory, or read-only memory (ROM)

– Conflicts with time-sharing systems, not supported by general-purpose operating systems.

– Mostly the province of special purpose operating systems.

• Soft real-time system

– Limited utility in industrial control or robotics

– Useful in applications (multimedia, virtual reality) requiring advanced operating-system features.

Operating System Concepts Silberschatz and Galvin 1999 1.24

Distributed Systems

• Network Operating System (NOS)

– provides file sharing

– provides communication scheme

– runs independently from other computers on the network

– Ex: NetWare

• Distributed Operating System

– less autonomy between computers

– gives the impression there is a single operating system controlling the network.

Operating System Concepts Silberschatz and Galvin 1999 1.25

O/S Evolution

Select an O/S subject

I/O structureStorageMemoryHardware protectionStorage hierarchy

Prepare "blackboard" presentation

HistoryKey conceptsEtc.

Group ActivityGroup Activity

Operating System Concepts Silberschatz and Galvin 1999 1.26

Module 2: Computer-System Structures

• Computer System Operation

• I/O Structure

• Storage Structure

• Storage Hierarchy

• Hardware Protection

• General System Architecture

Operating System Concepts Silberschatz and Galvin 1999 1.27

Computer-System Architecture

Registers are here

Also called RAM

Operating System Concepts Silberschatz and Galvin 1999 1.28

Computer-System Operation

• I/O devices and the CPU can execute concurrently.

• Each device controller is in charge of 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.

• Device controller informs CPU that it has finished its operation by causing an interrupt.

Operating System Concepts Silberschatz and Galvin 1999 1.29

Common Functions of Interrupts

• Interrupt transfers control to the interrupt service routine generally, through the interrupt vector, which contains the addresses of all the service routines.

• Interrupt architecture must save the address of the interrupted instruction.

• Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt.

• A trap is a software-generated interrupt caused either by an error or a user request.

• An operating system is interrupt driven.

Operating System Concepts Silberschatz and Galvin 1999 1.30

Interrupt Handling

• The operating system preserves the state of the CPU by storing registers and the program counter.

• Determines which type of interrupt has occurred:

– polling

– vectored interrupt system (note: PC’s use this)

• Separate segments of code determine what action should be taken for each type of interrupt

Operating System Concepts Silberschatz and Galvin 1999 1.31

Interrupt Time Line For a Single Process Doing Output

Operating System Concepts Silberschatz and Galvin 1999 1.32

I/O Structure

• After I/O starts, control returns to user program only upon I/O completion (blocking I/O, synchronous).

– wait instruction idles the CPU until the next interrupt– wait loop (contention for memory access).– At most one I/O request is outstanding at a time, no

simultaneous I/O processing.

• After I/O starts, control returns to user program without waiting for I/O completion (non-blocking I/O, asynchronous).

– System call – request to the operating system to allow user to wait for I/O completion.

– Device-status table contains entry for each I/O device indicating its type, address, and state.

– Operating system indexes into I/O device table to determine device status and to modify table entry to include interrupt.

Operating System Concepts Silberschatz and Galvin 1999 1.33

Direct Memory Access (DMA) Structure

• Used for high-speed I/O devices able to transmit informatin at close to memory speeds.

• Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention.

• Only on interrupt is generated per block, rather than the one interrupt per byte.

Operating System Concepts Silberschatz and Galvin 1999 1.34

Storage Structure

• Main memory – only large storage media that the CPU can access directly.

• Secondary storage – extension of main memory that provides large nonvolatile storage capacity.

• Magnetic disks – rigid metal or glass platters covered with magnetic recording material

– Disk surface is logically divided into tracks, which are subdivided into sectors.

– The disk controller determines the logical interaction between the device and the computer.

Operating System Concepts Silberschatz and Galvin 1999 1.35

Moving-Head Disk Mechanism

Operating System Concepts Silberschatz and Galvin 1999 1.36

Storage-Device Hierarchy

Operating System Concepts Silberschatz and Galvin 1999 1.37

Storage Hierarchy (Cont’d)

• Caches

– Main memory

– High speed system level (on-board caches)

– I/O controllers (ex: disk)

– Etc.

• Buffers

Operating System Concepts Silberschatz and Galvin 1999 1.38

Hardware Protection

• Dual-Mode Operation, Protection Rings, etc.

• I/O Protection

• Memory Protection

• CPU Protection

Operating System Concepts Silberschatz and Galvin 1999 1.39

Dual-Mode Operation

• Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1).

• When an interrupt or fault occurs hardware switches to monitor mode.

• Privileged instructions can be issued only in monitor mode.

monitor user

Interrupt/fault

set user mode

Operating System Concepts Silberschatz and Galvin 1999 1.40

I/O Protection

• All I/O instructions are privileged instructions.

• Must ensure that a user program could never gain control of the computer in monitor mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector).

Operating System Concepts Silberschatz and Galvin 1999 1.41

Memory Protection via Base and Limit

Operating System Concepts Silberschatz and Galvin 1999 1.42

Protection Hardware

• When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory.

• The load instructions for the base and limit registers are privileged instructions.

Operating System Concepts Silberschatz and Galvin 1999 1.43

CPU Protection

• Timer – interrupts computer after specified period to ensure operating system maintains control.

– Timer is decremented every clock tick.

– When timer reaches the value 0, an interrupt occurs.

• Timer commonly used to implement time sharing.

• Time also used to compute the current time.

• Load-timer is a privileged instruction.

Operating System Concepts Silberschatz and Galvin 1999 1.44

General-System Architecture

• Given the I/O instructions are privileged, how does the user program perform I/O?

• System call – the method used by a process to request action by the operating system.

– Usually takes the form of a trap to a specific location in the interrupt vector.

– Control passes through the interrupt vector to a service routine in the OS, and the mode bit is set to monitor mode.

– The monitor verifies that the parameters are correct and legal, executes the request, and returns control to the instruction following the system call.

Operating System Concepts Silberschatz and Galvin 1999 1.45

Use of A System Call to Perform I/O

Operating System Concepts Silberschatz and Galvin 1999 1.46

Module 3: Operating-System Structures

• System Components

• Operating System Services

• System Calls

• System Programs

• System Structure

• Virtual Machines

• System Design and Implementation

• System Generation

Operating System Concepts Silberschatz and Galvin 1999 1.47

Common System Components

• Process Management

• Main Memory Management

• Secondary-Storage Management

• I/O System Management

• File Management

• Protection System

• Networking

• Command-Interpreter System

Operating System Concepts Silberschatz and Galvin 1999 1.48

Process Management

• A process is a program in execution. A process needs certain resources, including CPU time, memory, files, and I/O devices, to accomplish its task.

• The operating system 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

Operating System Concepts Silberschatz and Galvin 1999 1.49

Unix Process Creation

Operating System Concepts Silberschatz and Galvin 1999 1.50

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 operating system is responsible for the following activities in connections with memory management:

– Keep track of which parts of memory are currently being used and by whom.

– Decide which processes to load when memory space becomes available.

– Allocate and deallocate memory space as needed.

Operating System Concepts Silberschatz and Galvin 1999 1.51

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.

• Most modern computer systems use disks as the principle on-line storage medium, for both programs and data.

• The operating system is responsible for the following activities in connection with disk management:

– Free space management

– Storage allocation

– Disk scheduling

Operating System Concepts Silberschatz and Galvin 1999 1.52

I/O System Management

• The I/O system consists of:

– A buffer-caching system

– A general device-driver interface

– Drivers for specific hardware devices

Operating System Concepts Silberschatz and Galvin 1999 1.53

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.

• The operating system is responsible for the following activities in connections 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.

Operating System Concepts Silberschatz and Galvin 1999 1.54

Protection System

• 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.

Operating System Concepts Silberschatz and Galvin 1999 1.55

Command-Interpreter System

• 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

Operating System Concepts Silberschatz and Galvin 1999 1.56

Command-Interpreter System (Cont.)

• The program that reads and interprets control statements is called variously:

– control-card interpreter

– command-line interpreter (command.com in DOS)

– shell (in UNIX)

Its function is to get and execute the next command statement.

• Most modern systems have a graphical front end (Windows, Unix/Linux KDE, etc.) to this.

Operating System Concepts Silberschatz and Galvin 1999 1.57

Operating System Services

• Program execution – system capability to load a program into memory and to run it.

• I/O operations – since user programs cannot execute I/O operations directly, the operating system ust 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.

• Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs.

Operating System Concepts Silberschatz and Galvin 1999 1.58

Additional Operating System Functions

Additional functions exist not for helping the user, but rather for ensuring efficient system operations.

• Resource allocation – allocating resources to multiple users or multiple jobs running at the same time.

• Accounting – keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics.

• Protection – ensuring that all access to system resources is controlled.

Operating System Concepts Silberschatz and Galvin 1999 1.59

System Calls

• System calls provide the interface between a running program and the operating system.

– 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++)

• 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.

– Push (store) the parameters onto the stack by the program, and pop off the stack by operating system.

Operating System Concepts Silberschatz and Galvin 1999 1.60

MS-DOS Execution

At System Start-up Running a Program

Operating System Concepts Silberschatz and Galvin 1999 1.61

UNIX Running Multiple Programs

Operating System Concepts Silberschatz and Galvin 1999 1.62

Communication Models

Msg Passing Shared Memory

Operating System Concepts Silberschatz and Galvin 1999 1.63

System Programs

• System programs provide a convenient environment for program development and execution. The can be divided into:

– File manipulation

– Status information

– File modification

– Programming language support

– Program loading and execution

– Communications

– Application programs

• Most users’ view of the operation system is defined by system programs, not the actual system calls.

Operating System Concepts Silberschatz and Galvin 1999 1.64

System Structure – Simple Approach

• MS-DOS – written to provide the most functionality in the least space

– not divided into modules

– Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated

Operating System Concepts Silberschatz and Galvin 1999 1.65

MS-DOS Layer Structure

Operating System Concepts Silberschatz and Galvin 1999 1.66

System Structure – Simple Approach (Cont.)

• UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts.

– Systems programs

– The kernel Consists of everything below the system-call interface

and above the physical hardware Provides the file system, CPU scheduling, memory

management, and other operating-system functions; a large number of functions for one level.

Operating System Concepts Silberschatz and Galvin 1999 1.67

UNIX(BSD) System Structure

Operating System Concepts Silberschatz and Galvin 1999 1.68

System Structure – 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.

• Bottom layers are the kernel. Some systems(NT, MACH) use a micro kernel architecture.

Operating System Concepts Silberschatz and Galvin 1999 1.69

NT Architecture

Operating System Concepts Silberschatz and Galvin 1999 1.70

Virtual Machines

•Host one environment on another– Linux dosemu– Mainframe VM systems– Mac PowerPC 6800 emulation

Operating System Concepts Silberschatz and Galvin 1999 1.71

Virtual Machines (Cont’d)

Non-virtual Machine Virtual Machine

Operating System Concepts Silberschatz and Galvin 1999 1.72

Operating System Implementation

• Traditionally written in assembly language, operating systems can now be written in higher-level languages.

• Code written in a high-level language:

– can be written faster.

– is more compact.

– is easier to understand and debug.

• An operating system is far easier to port (move to some other hardware) if it is written in a high-level language (NT, Unix)

Operating System Concepts Silberschatz and Galvin 1999 1.73

System Generation (SYSGEN)

• Operating systems are designed to run on any of a class of machines; the system must be configured for each specific computer site.

• SYSGEN program obtains information concerning the specific configuration of the hardware system.

• Booting – starting a computer by loading the kernel.

• Bootstrap program – code stored in ROM that is able to locate the kernel, load it into memory, and start its execution.

Operating System Concepts Silberschatz and Galvin 1999 1.74

System Services

• Select a service area:

– Program execution

– I/O operation

– File manipulation

– Error detection

– Communications

• Give a brief 5 – 10 minute presentation

– How performed

– Data structures

– 1 presenter is fine

Group Activity

Operating System Concepts Silberschatz and Galvin 1999 1.75

Next Week (WS2): Agenda

• Reading: ch’s 4-7. Note: scan only material related to graph theory

• Homework Review: ch’s 4-7

• Study group papers & presentations

• Lecture & discussion on process types & concepts

• Group activity on processes and resources

• Lecture & discussion on resource allocation

• Group activity on process management

• Summary & preview

Operating System Concepts Silberschatz and Galvin 1999 1.76

Next Week (WS2): Study Group

• How O/S manages processes & concurrency

– process scheduling

– interprocess communication

– process synchronization

– deadlocks

– etc.

• 3 - 5 page paper

• Presentation

– 5 - 10 minutes

– 1 person can represent group