op sy 03 ch 01

34
1 Chapter 1: Introduction C eng 334 -O perating System s 1-1 Chapter 1: Introduction W hatisthe aim ofthe subject? W hy are O Sesim portant? W hatisan O S? A bitofhistory Som e basic O S concepts H ow doesan O S w ork? O S Structures

Upload: google

Post on 22-May-2015

375 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Op Sy 03 Ch 01

1

Chapter 1: Introduction

Ceng 334 - Operating Systems 1-1

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

Page 2: Op Sy 03 Ch 01

2

What is the aim of the sucject

Ceng 334 - Operating Systems 1-2

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.

Page 3: Op Sy 03 Ch 01

3

Computer system components

Ceng 334 - Operating Systems 1-3

Computer System Components

• Application Software : Bank automation system, airline reservations, payroll etc.

• System Software : OS, data base, compilers, editors etc.

APPLICATION SOFTWARE

SYSTEM SOFTWARE

PHYSICAL HARDWARE

Page 4: Op Sy 03 Ch 01

4

What is the Software

Ceng 334 - Operating Systems 1-4

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

Page 5: Op Sy 03 Ch 01

5

Why is the Operating system İmportan?

Ceng 334 - Operating Systems 1-5

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

Page 6: Op Sy 03 Ch 01

6

What is an Operating system?

Ceng 334 - Operating Systems 1-6

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

Page 7: Op Sy 03 Ch 01

7

Computer without an operating system

Ceng 334 - Operating Systems 1-7

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

Page 8: Op Sy 03 Ch 01

8

Where does the operating system fit?

Ceng 334 - Operating Systems 1-8

Where does the OS Fit?

HardwareCPU & MemoryI/O Devices

Operating System

System Calls

Users and User Programs

Page 9: Op Sy 03 Ch 01

9

History: First Generation

Ceng 334 - Operating Systems 1-9

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

Page 10: Op Sy 03 Ch 01

10

History: Second Generation

Ceng 334 - Operating Systems 1-10

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)

Page 11: Op Sy 03 Ch 01

11

Ceng 334 - Operating Systems 1-11

• 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

Page 12: Op Sy 03 Ch 01

12

Ceng 334 - Operating Systems 1-12

• Applications are mostly scientific and engineering calculations (eg., solution of partial differential equations)

• High level languages such as FORTRAN and COBOL

Page 13: Op Sy 03 Ch 01

13

History: Thirs Generation

Ceng 334 - Operating Systems 1-13

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 VDU’s)

• Multics OS - original UNIX

Page 14: Op Sy 03 Ch 01

14

Ceng 334 - Operating Systems 1-14

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

Page 15: Op Sy 03 Ch 01

15

History: Fourth Generation

Ceng 334 - Operating Systems 1-15

History:Fourth Generation (1980-1990)

• Large scale integration

• Personal computers

• CP/M, MS DOS, Unix operating systems

• Networks

Page 16: Op Sy 03 Ch 01

16

Now

Ceng 334 - Operating Systems 1-16

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)

Page 17: Op Sy 03 Ch 01

17

Important Points

Ceng 334 - Operating Systems 1-17

Important Points

• OS provides – a simpler, more powerful interface

– higher level services

• OS services only accessed via system calls

• Users and programs can’t directly access the hardware

Set of System Calls (APIs) is what programs think the operating system is.

Page 18: Op Sy 03 Ch 01

18

Same Operating System Concepts

Ceng 334 - Operating Systems 1-18

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

Page 19: Op Sy 03 Ch 01

19

Same Operating System Concepts

Ceng 334 - Operating Systems 1-19

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.

Page 20: Op Sy 03 Ch 01

20

Producing an Executable

Ceng 334 - Operating Systems 1-20

Producing an Executable

Source Code Object File

Compile

Libraries and other Object files

Link

Executable

Page 21: Op Sy 03 Ch 01

21

Ceng 334 - Operating Systems 1-21

#include <sys/types.h>#include <dirent.h>#include "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);

}

Page 22: Op Sy 03 Ch 01

22

Ceng 334 - Operating Systems 1-22

#include <sys/types.h>#include <dirent.h>#include "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);

}

Functions supplied by systemlibraries.These functions will contain atrap instruction.

Page 23: Op Sy 03 Ch 01

23

Ceng 334 - Operating Systems 1-23

RAM

User Program #1

User Program #2

trap 002

Kernel

1

2

3

System/Kernel Mode

User Mode

1. Program performs trap2. OS determines service

number3. Service is located and

executed.4. Control returns to user

program.4

Based on a diagram from “Modern Operating Systems” byAndrew Tanenbaum.

Page 24: Op Sy 03 Ch 01

24

Operating System Structures

Ceng 334 - Operating Systems 1-24

OS Structures

• Monolithic systems

• Hierarchy of layers

• Virtual machines

• Micro-kernel (client/server) model

Page 25: Op Sy 03 Ch 01

25

Monolithic System

Ceng 334 - Operating Systems 1-25

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)

InterruptHandler

Service routine

SVC

Program

Page 26: Op Sy 03 Ch 01

26

Ceng 334 - Operating Systems 1-26

• 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

Page 27: Op Sy 03 Ch 01

27

Layered System

Ceng 334 - Operating Systems 1-27

Layered System

• Structure of “THE” OS (a batch OS)

5. OPERATOR FUNCTIONS4. USER PROGRAMS3. I/O MANAGEMENT2. OPERATOR-PROCESS COMMUNICATION1. MEMORY MANAGEMENT (Swapping)0. CPU MANAGEMENT (Process switching)

Page 28: Op Sy 03 Ch 01

28

Ceng 334 - Operating Systems 1-28

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)

Page 29: Op Sy 03 Ch 01

29

Ceng 334 - Operating Systems 1-29

4. User programs

5. Operator

• Synchronisation between layers : Hardware and software (semaphores) interrupts

• Each layer provides some sort of a “virtual machine”

Page 30: Op Sy 03 Ch 01

30

Virtual Machine

Ceng 334 - Operating Systems 1-30

Virtual Machines

Physical HardwareVirtual Machine

OS1 OS2 OS3 OS4

User Programs

• VM provides “n” duplicates of physical hardware using software. So different Osescan work in the same machine at the same time

Page 31: Op Sy 03 Ch 01

31

What is wrong

Ceng 334 - Operating Systems 1-31

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

Page 32: Op Sy 03 Ch 01

32

Micro-Kernel Model

Ceng 334 - Operating Systems 1-32

Micro-Kernel (Client/Server) Model• OS is a minimal core known as Kernel.

OS Kernel

Prog1 Prog2 ….. File Server Terminal Server Memory Server

Messages for Communication

Page 33: Op Sy 03 Ch 01

33

Ceng 334 - Operating Systems 1-33

• 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

Page 34: Op Sy 03 Ch 01

34

Characteristics of Kernel

Ceng 334 - Operating Systems 1-34

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