Sie sind auf Seite 1von 62

Chapter 1

Introduction

Chapter 1: Introduction
Chapter 1: Introduction
What is the aim of the subject? Why are OSes important? What is an OS? A bit of history Some basic OS concepts How does an OS work? OS Structures
Ceng 334 - Operating Systems
1-1

What is the aim of the sucject


The Aim of the Subject
WILL NOT TEACH YOU HOW TO USE AN OPERATING SYSTEM. It will examine the way in which an OS works the algorithms and data structures inside an OS the problems, solutions and trade offs in designing an OS TO ACHIEVE AN UNDERSTANDING OF HOW AN OPERATING SYSTEM WORKS.
Ceng 334 - Operating Systems
1-2

What is an Operating System


It is an extended machine
Hides the messy details which must be performed Presents user with a virtual machine, easier to use

It is a resource manager
Each program gets time with the resource Each program gets space on the resource
4

Computer system components


Computer System Components
APPLICATION SOFTWARE SYSTEM SOFTWARE PHYSICAL HARDWARE Application Software : Bank automation system, airline reservations, payroll etc. System Software : OS, data base, compilers, editors etc.
Ceng 334 - Operating Systems
1-3

Introduction

A computer system consists of


hardware system programs application programs

What is the Software


What is SYSTEM SOFTWARE?
System software provides the environment and the tools to create the application software It is also the interface between the hardware and the applications

Ceng 334 - Operating Systems

1-4

Why is the Operating system mportan?


Why is the OS Important?
The operating system is the foundation upon which all computing work is performed. Knowledge of the internals of an OS is essential to achieve efficiency in
building software applications deciding upon a computing platform

Ceng 334 - Operating Systems

1-5

What is an Operating system?


What is an Operating System?
A big, complex program (sometimes many) It has two main purposes in life
An interface between the user and the hardware (provides a virtual machine)
Provide efficient, safe management of computing resources

Ceng 334 - Operating Systems

1-6

Computer without an operating system


Life without an OS
Every programmer would
have to know the hardware be able to access the hardware

Every program
would contain code to do the same thing probably do something wrong

Ceng 334 - Operating Systems

1-7

10

Where does the operating system fit?

11

History of Operating Systems (1)

Early batch system


bring cards to 1401 read cards to tape put tape on 7094 which does computing put tape on 1401 which prints output

12

History of Operating Systems (2)


First generation 1945 - 1955
vacuum tubes, plug boards

Second generation 1955 - 1965


transistors, batch systems

Third generation 1965 1980


ICs and multiprogramming

Fourth generation 1980 present


personal computers
13

History of Operating Systems (3)

Structure of a typical FMS job 2nd generation 14

History of Operating Systems (4)

Multiprogramming system
three jobs in memory 3rd generation
15

The Operating System Zoo


Mainframe operating systems Server operating systems Multiprocessor operating systems Personal computer operating systems Real-time operating systems Embedded operating systems Smart card operating systems
16

History: First Generation


History : First Generation (1945-1955)
Vacuum tubes No operating system Programming is done by wiring a plug board Applications are mostly numerical calculations (trajectory computations, computation of tables such as sine, cosine etc.)
Ceng 334 - Operating Systems
1-9

17

History: Second Generation


History: Second Generation (1955-1965)
Transistors Commercially produced computers Very expensive and very slow computers compared with your old PC at home Batch operation (collect jobs, run in one go, print all outputs)

Ceng 334 - Operating Systems

1-10

18

Spooling (Simultaneous Peripheral Operation On-line)


off-line spooling on-line spooling

Off-line spooling : replace slow I/O devices with I/O dedicated computers so that the main system sees these machines as its I/O devices
Ceng 334 - Operating Systems
1-11

19

Applications are mostly scientific and engineering calculations (eg., solution of partial differential equations) High level languages such as FORTRAN and COBOL

Ceng 334 - Operating Systems

1-12

20

History: Thirs Generation


History: Third Generation (1965-1980)
Integrated circuits (small scale) packed as chips I/O processors (channels) which can work in parallel with CPU - Multiprogramming On-line spooling (using channels) Time-sharing (TTY terminals and VDUs) Multics OS - original UNIX
Ceng 334 - Operating Systems
1-13

21

Minicomputers - Cheaper than mainframes but with limited hardware (eg. DEC PDPx)

Ceng 334 - Operating Systems

1-14

22

History: Fourth Generation


History: Fourth Generation (1980-1990)
Large scale integration Personal computers CP/M, MS DOS, Unix operating systems Networks

Ceng 334 - Operating Systems

1-15

23

Now
Now!
Client/Server computation Clients : PCs, workstations running under Windows and UNIX operating systems Servers : systems that run under UNIX and Windows NT Internet and intranet networking (WWW)

Ceng 334 - Operating Systems

1-16

24

Important Points
Important Points
OS provides
a simpler, more powerful interface higher level services

OS services only accessed via system calls Users and programs cant directly access the hardware Set of System Calls (APIs) is what programs think the operating system is.
Ceng 334 - Operating Systems
1-17

25

Same Operating System Concepts


Some OS Concepts
Kernel
The main OS program. Contains code for most services. Always in primary memory

Device Drivers
Programs that provide a simple, consistent interface to I/O devices Typically part of the kernel

Ceng 334 - Operating Systems

1-18

26

Same Operating System Concepts


Some OS Concepts
Program
A static file of machine code on a disk

Process
A program in execution. The collection of OS data structures and resources owned by a program while it is running.

Ceng 334 - Operating Systems

1-19

27

Producing an Executable
Producing an Executable
Source Code Object File Executable

Compile

Link

Libraries and other Object files

Ceng 334 - Operating Systems

1-20

28

#include #include #include

<sys/types.h> <dirent.h> "ourhdr.h"

int main(int argc, char *argv[]) { DIR *dp; struct dirent *dirp; if (argc != 2) err_quit("a single argument (the directory name) is required"); if ( (dp = opendir(argv[1])) == NULL) err_sys("can't open %s", argv[1]); while ( (dirp = readdir(dp)) != NULL) printf("%s\n", dirp->d_name); closedir(dp); exit(0); } Ceng 334 - Operating Systems
1-21

29

#include #include #include

<sys/types.h> <dirent.h> "ourhdr.h"

int main(int argc, char *argv[]) { DIR *dp; struct dirent *dirp;

Functions supplied by system libraries. These functions will contain a trap instruction.

if (argc != 2) err_quit("a single argument (the directory name) is required"); if ( (dp = opendir(argv[1])) == NULL) err_sys("can't open %s", argv[1]); while ( (dirp = readdir(dp)) != NULL) printf("%s\n", dirp->d_name); closedir(dp); exit(0); } Ceng 334 - Operating Systems
1-22

30

31

Operating System Structures


OS Structures
Monolithic systems Hierarchy of layers Virtual machines Micro-kernel (client/server) model

Ceng 334 - Operating Systems

1-24

32

Monolithic System
Monolithic System
OS has no structure but is a collection of procedures with well defined calling interfaces Program - OS interface is via supervisor calls (SVC)
SVC Program Interrupt Handler Service routine

Ceng 334 - Operating Systems

1-25

33

OS code is a binded object program and its source code may be logically divided into
OS main program System call service routines Utility procedures which help service routines

Ceng 334 - Operating Systems

1-26

34

Operating System Structure (1)

Simple structuring model for a monolithic system


35

Layered System
Layered System
Structure of THE OS (a batch OS)
5. OPERATOR FUNCTIONS 4. USER PROGRAMS 3. I/O MANAGEMENT 2. OPERATOR-PROCESS COMMUNICATION 1. MEMORY MANAGEMENT (Swapping) 0. CPU MANAGEMENT (Process switching)

Ceng 334 - Operating Systems

1-27

36

Operating System Structure (2)

Structure of the THE operating system

37

0. Process switching, multi programming, CPU scheduling 1. Memory and swap space (disk) management (segment controller) 2. Message interpretation, job control (JCL) functions 3. I/O management (virtual peripherals)
Ceng 334 - Operating Systems
1-28

38

4. User programs 5. Operator Synchronisation between layers : Hardware and software (semaphores) interrupts Each layer provides some sort of a virtual machine
Ceng 334 - Operating Systems
1-29

39

Virtual Machine
Virtual Machines User Programs OS1 OS2 OS3 OS4 Virtual Machine Physical Hardware
VM provides n duplicates of physical hardware using software. So different Oses can work in the same machine at the same time
1-30

Ceng 334 - Operating Systems

40

Operating System Structure (3)

Structure of VM/370 with CMS


41

What is wrong
What is wrong?
OS is one large program that provides all the required services. Anytime you add a new device you must
get a device driver for the device recompile the kernel with the new device driver reboot the machine so the new kernel will be used

Ceng 334 - Operating Systems

1-31

42

Micro-Kernel Model
Micro-Kernel (Client/Server) Model
OS is a minimal core known as Kernel.
Messages for Communication Prog1 Prog2

.. File Server

Terminal Server Memory Server

OS Kernel

Ceng 334 - Operating Systems

1-32

43

Operating System Structure (4)

The client-server model


44

Operating System Structure (5)

The client-server model in a distributed system


45

The kernel contains the minimum of function


memory management basic CPU management inter-process communication (messages) I/O support

Other functionality provided by user level processes


Ceng 334 - Operating Systems
1-33

46

Characteristics of Kernel
Characteristics of Kernel
Makes use of message passing Easy to replace server processes Can have multiple personalities Easier to write and port OS Design is perfect for distributed systems

Less performance
Ceng 334 - Operating Systems
1-34

47

Computer Hardware Review (1)


Monitor

Bus

Components of a simple personal computer


48

Computer Hardware Review (2)

(a) A three-stage pipeline (b) A superscalar CPU


49

Computer Hardware Review (3)

Typical memory hierarchy


numbers shown are rough approximations 50

Computer Hardware Review (4)

Structure of a disk drive


51

Computer Hardware Review (5)

One base-limit pair and two base-limit pairs


52

Computer Hardware Review (6)

(a)

(b)

(a) Steps in starting an I/O device and getting interrupt (b) How the CPU is interrupted 53

Computer Hardware Review (7)

Structure of a large Pentium system

54

Operating System Concepts (1)

A process tree
A created two child processes, B and C B created three child processes, D, E, and F
55

Operating System Concepts (2)

(a) A potential deadlock. (b) an actual deadlock.


56

Operating System Concepts (3)

File system for a university department

57

Operating System Concepts (4)

Before mounting,
files on floppy are inaccessible

After mounting floppy on b,


files on floppy are part of file hierarchy
58

Operating System Concepts (5)

Two processes connected by a pipe


59

System Calls (1)


A stripped down shell:
while (TRUE) { type_prompt( ); read_command (command, parameters) if (fork() != 0) { /* Parent code */ waitpid( -1, &status, 0); } else { /* Child code */ execve (command, parameters, 0); } } /* repeat forever */ /* display prompt */ /* input from terminal */ /* fork off child process */ /* wait for child to exit */

/* execute command */

60

System Calls (5)

Some Win32 API calls

61

Metric Units

The metric prefixes


62

Das könnte Ihnen auch gefallen