Sie sind auf Seite 1von 21

Operating System Course

Dr. Abeer Mohamed El-Korany


Computer Science Department
Faculty Of computer and Information

a.korani@fci-cu.edu.eg

Dr.Abeer El-korany 2009

Outline Course Overview


Course Description
Assessment
Course Text

Operating System Course

1.2

Dr.Abeer El-koranyl 2009

Course Description
Part 1: Overview
z

Introduction

Operating-System Structures

Part 2: Process Management


z

Processes

Threads

CPU Scheduling

Part 3: Memory Management


z

Main Memory

Virtual Memory

During Lab time, teaching operating system concepts is done through Linux.

KNOPPIX is used as a productive Linux system for the desktop


Operating System Course

1.3

Dr.Abeer El-koranyl 2009

Grading System
Grades will be based on 100 possible points, using

the following distribution schedule:


Assignments: 15%
Mid-term Exam : 10%
Final Project: 10 %
Term Report : 5%
Final Exam: 60%

Operating System Course

1.4

Dr.Abeer El-koranyl 2009

References
Text Book:
1. Operating System Concepts, 8th
Silberschatz, Galvin and Gagne 2009
2. Modern Operating Systems, A.
Tanenbaum:Prentice-Hall, 2nd Edition, 2008

Operating System Course

1.5

Dr.Abeer El-koranyl 2009

Chapter 1: Introduction
Computer System Overview
Computer-System Structure
What is an Operating System?
Computer-System Organization
Operating-System Operations
Process Management
Memory Management
Storage Management

Operating System Course

1.6

Dr.Abeer El-koranyl 2009

Computer System Structure

Operating System Course

1.7

Dr.Abeer El-koranyl 2009

Computer System Structure


Computer system can be divided into four components

Hardware provides basic computing resources


 CPU,

memory, I/O devices

Operating system
 Controls

and coordinates use of hardware among various


applications and users

Application programs define the ways in which the


system resources are used to solve the computing problems of
the users
 Word

processors, web browsers, database systems, video


games

Users
 People,

machines, other computers

Operating System Course

1.8

Dr.Abeer El-koranyl 2009

Computer Abstraction Layers

A computer system consists of

Operating System Course

hardware

system programs

application programs

1.9

Dr.Abeer El-koranyl 2009

What is an Operating System?


A program that acts as an intermediary between a user

of a computer and the computer hardware.


OS is a control program
z

Controls execution of programs to prevent errors


and improper use of the computer

The one program running at all times on the computer

is the kernel. Everything else is either a system


program (ships with the operating system) or an
application program
Operating System Course

1.10

Dr.Abeer El-koranyl 2009

Operating System Definition


OS is a resource allocator
z

Allow multiple programs to run at the same time

Manage and protect memory, I/O devices, and other resources

Includes multiplexing (sharing) resources in two different ways:


 In

time

 In

space

OS is a control program
z

Controls execution of programs to prevent errors and improper use


of the computer

Control Resources among:




Users; Programs; Processors;


Control means: sharing/multiplexing, monitoring, protection,
report/payment

Operating System Course

1.11

Dr.Abeer El-koranyl 2009

Operating System Objectives


Operating system goals:
z Convenience
Makes

the computer more convenient to use

z Efficiency
Allows

computer system resources to be


used in an efficient manner

Operating System Course

1.12

Dr.Abeer El-koranyl 2009

Operating System (cont.)


The two Views of an Operating System
z

TopTop-down View:

An Extended Machine
 Hides

the details which must be performed

 Presents

user with a virtual machine, easier to use

BottomBottom-up View:

A Resource Manager
 Each

program gets time with the resource

 Each

program gets space on the resource

Operating System Course

1.13

Dr.Abeer El-koranyl 2009

Role Of Operating system (User View)


Program execution

the O/S loads programs and data into memory, initializes I/O devices
and files, schedules the execution of programs

Access to I/O devices


the O/S hides I/O device details from applications (direct I/O access is
forbidden) and offers a simplified I/O interface

Controlled access to files


the O/S organizes data into files, controls access to the files (create,
delete, read, write) and preserves their integrity

Communications
the O/S allows exchange of information between processes, which are

possibly executing on different computers

Error detection and response


the O/S properly handles hardware failures and software errors with the
least impact to running applications (ending, retrying Or reporting)

Operating System Course

1.14

Dr.Abeer El-koranyl 2009

Computer System Organization


Computer-system operation
z

One or more CPUs, device controllers connect through


common bus providing access to shared memory

Concurrent execution of CPUs and devices competing for


memory cycles

Operating System Course

1.15

Dr.Abeer El-koranyl 2009

Hardware Elements
Processor
Main Memory
z
z

referred to as real memory or primary memory


volatile

I/O modules
z

secondary memory devices

communications equipment

terminals

System bus
z

communication among processors, memory, and I/O


modules

Operating System Course

1.16

Dr.Abeer El-koranyl 2009

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 Course

1.17

Dr.Abeer El-koranyl 2009

Computer-System Operation
Computer Startup
bootstrap program is loaded at power-up or

reboot
Typically

stored in ROM or EEPROM,


generally known as firmware

Initialized

all aspects of system

Loads

operating system kernel and starts


execution

Operating System Course

1.18

Dr.Abeer El-koranyl 2009

Processor

Operating System Course

1.19

Dr.Abeer El-koranyl 2009

Instruction Cycle
The processor fetches the instruction from memory
Program counter (PC) holds address of the instruction to be

fetched next

Program counter is incremented after each fetch

Fetched instruction is placed in the instruction register


Types of instructions
z

transfer data between processor and memory

data transferred to or from a peripheral device

arithmetic or logic operation on data

Operating System Course

1.20

Dr.Abeer El-koranyl 2009

Interrupts
An interruption of the normal sequence of execution
Most I/O devices are slower than the processor

(writing to a line printer)


z

Processor must pause to wait for device

Interrupts allow the processor to execute other

instructions while an I/O operation is in progress


Process being interrupted must be suspended in

such a way so that it can be resumed once the


operation is complete
Improves processing efficiency
Operating System Course

1.21

Dr.Abeer El-koranyl 2009

Interrupt Cycle

Operating System Course

1.22

Dr.Abeer El-koranyl 2009

Interrupt Cycle
zInterrupt

transfers control to the interrupt


service routine generally, through the interrupt
vector, which contains the addresses of all the
service routines.
zInterrupt

architecture must save the address of


the interrupted instruction.
zAn

operating system is interrupt driven.

Operating System Course

1.23

Dr.Abeer El-koranyl 2009

Interrupt Handling
A program that determines nature of the interrupt and performs

whatever actions are needed


The operating system preserves the state of the CPU by storing

registers and the program counter.


Determines which type of interrupt has occurred:
z

Program
 arithmetic

overflow

 division

by zero

 execute

illegal instruction

 reference

outside users memory space

I/O

Hardware failure

Control is transferred to this program

Operating System Course

1.24

Dr.Abeer El-koranyl 2009

I/O Structure
After I/O starts, control returns to user program only upon I/O

completion.
z

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

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 Course

1.25

Dr.Abeer El-koranyl 2009

Device-Status Table

Operating System Course

1.26

Dr.Abeer El-koranyl 2009

Input Device example


Device controller


Status register

 (ready,


busy, interrupt, )

Data registers

A simple mouse design


z

Put (X, Y) in data registers on a move

Interrupt

Input on an interrupt
z

Read values in X, Y registers

Set ready bit

Wake up a process/thread or execute a piece of code

Operating System Course

1.27

Dr.Abeer El-koranyl 2009

Direct Memory Access (DMA) Structure


I/O exchanges occur directly with memory
Processor grants I/O module authority to read from

or write to memory
Processor is free to do other things
Device controller transfers blocks of data from buffer

storage directly to main memory without CPU


intervention.
Only one interrupt is generated per block, rather than

the one interrupt per byte.

Operating System Course

1.28

Dr.Abeer El-koranyl 2009

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


z

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 Course

1.29

Dr.Abeer El-koranyl 2009

Storage Hierarchy
Storage systems organized in hierarchy.
z

Speed

Cost

Volatility

Decreasing cost per bit


z

Increasing capacity

Increasing access time

Decreasing frequency of access of the memory by the processor

Caching copying information into faster storage

system; main memory can be viewed as a last cache for


secondary storage.
Operating System Course

1.30

Dr.Abeer El-koranyl 2009

Storage-Device Hierarchy

Operating System Course

1.31

Dr.Abeer El-koranyl 2009

Caching
Important principle, performed at many levels in a

computer (in hardware, operating system, software)


Information in use copied from slower to faster storage

temporarily
Faster storage (cache) checked first to determine if

information is there
z

If it is, information used directly from the cache (fast)

If not, data copied to cache and used there

Cache smaller than storage being cached


z

Cache management important design problem

Cache size and replacement policy

Operating System Course

1.32

Dr.Abeer El-koranyl 2009

Cache Memory
A portion of main memory used as a buffer to temporarily

to hold data for the disk


z

Disk writes are clustered

Some data written out may be referenced again. The data are
retrieved rapidly from the software cache instead of slowly from
disk

Operating System Course

1.33

Dr.Abeer El-koranyl 2009

Performance of Various Levels of Storage


Movement between levels of storage hierarchy can be explicit or

implicit

Operating System Course

1.34

Dr.Abeer El-koranyl 2009

Operating-System Operations
Interrupt driven by hardware
Software error or request creates exception or trap
z

Division by zero, request for operating system service

Other process problems include infinite loop, processes modifying

each other or the operating system


Dual-mode operation allows OS to protect itself and other system

components
z

User mode and kernel mode

Mode bit provided by hardware


 Provides

ability to distinguish when system is running user


code or kernel code

 Some

instructions designated as privileged, only


executable in kernel mode

 System

call changes mode to kernel, return from call resets


it to user

Operating System Course

1.35

Dr.Abeer El-koranyl 2009

Transition from User to Kernel Mode


Timer to prevent infinite loop / process hogging resources
z

Set interrupt after specific period

Operating system decrements counter

When counter zero generate an interrupt

Set up before scheduling process to regain control or terminate


program that exceeds allotted time

Operating System Course

1.36

Dr.Abeer El-koranyl 2009

Types of O/S
Mainframe systems
Desktop & laptop systems
Parallel system
Real-time systems

Operating System Course

1.37

Dr.Abeer El-koranyl 2009

Types of Operating Systems


Mainframe systems
Characteristics of mainframe systems
The first computers used to tackle various applications and still

found today in corporate data centers

room-sized, high I/O capacity, reliability, security, tech support

mainframes focus on I/O-bound business data applications


(supercomputers focus on CPU-bound scientific calculations)

Mainframes provide three main functions

batch processing: insurance claims, store sales reporting, etc.

transaction processing: credit card, bank account, etc.

time-sharing ( sessions): multiple users querying a database

Operating System Course

1.38

Dr.Abeer El-koranyl 2009

Parallel systems

Operating System Course

1.39

Dr.Abeer El-koranyl 2009

Real-time systems
systems controlling scientific experiments, medical imaging

systems, industrial control systems, some display systems

Hard real-time: critical tasks are guaranteed on time

secondary storage limited or absent, data stored in short term

memory, or read-only memory (ROM)

conflicts with time-sharing systems and virtual memory delays

Soft real-time: critical tasks just get higher priority


more useful in applications requiring tight but not strict response

times ( multimedia, virtual reality, robotic exploration)

Operating System Course

1.40

Dr.Abeer El-koranyl 2009

OS - Main Components

Process management
z

process creation; deletion; suspension

process synchronization; communication

Main-memory management
z

Manage used parts and their current users

Select processes to load

Allocate memory to running processes

Secondary storage management


z

Free-space management

Storage allocation

File system management


z

File + directory creation; deletion

File manipulation primitives

Mapping files onto secondary storage

Operating System Course

1.41

Dr.Abeer El-koranyl 2009

OS - Main Components (cont.)


I/o system management
z general device-driver interface
z

Drivers for specific hardware devices

Protection system
z Distinguish between authorized and unauthorized usage
z

Provide means of enforcement

Command-interpreter System
z

Control statements that deal with process creation and


management + I/o handling + file-system access + protection +
networking

Operating System Course

1.42

Dr.Abeer El-koranyl 2009

Das könnte Ihnen auch gefallen