Sei sulla pagina 1di 49

INTRODUCTION TO OPERATING SYSTEMS

1 SPRING 2011 - 102

O PERATING S YSTEMS

To understand the operating system is to understand the working of the entire computer system , because it is the operating system that manages each and every piece of hardware and software.

In this course we will explore what operating systems are, how they work, what they do And why?

SPRING 2011 - 102

OUTLINE

What is operating system operating systems operations

Operating system software Introduction to operating systems

Operating system Architecture Operating system Organization

SPRING 2011 - 102

W HAT IS AN O PERATING S YSTEM

SPRING 2011 - 102

W HAT IS AN O PERATING S YSTEM ?

Computer System

Software (programs)
Hardware (physical machine and electronic components)

Operating System

Part of computer system (software)


Consider it as executive manager which manages all hardware and software

Controls every file, device, section of main memory and nanosecond of processing time Controls who can use the system Controls how system is used
SPRING 2011 - 102

SPRING 2011 - 102

O PERATING S YSTEM D EFINITION

OS is a resource allocator

Manages all resources Decides between conflicting requests for efficient and fair resource use

OS is a control program

Controls execution of programs to prevent errors and improper use of the computer
SPRING 2011 - 102

O PERATING S YSTEM S OFTWARE

SPRING 2011 - 102

O PERATING S YSTEM S OFTWARE

Includes four essential subsystem managers


Memory Manager (management programs) Processor Manager Device Manager File Manager

Network Manager (fifth subsystem manager)


In all modern operating systems Assumes responsibility for networking tasks


SPRING 2011 - 102

10

O PERATING S YSTEM S OFTWARE


( CONTINUED )

SPRING 2011 - 102

11

O PERATING S YSTEM S OFTWARE


( CONTINUED )

User Command Interface

Provides user communication

User issues commands to operating system

Unique to each operating system

May vary between versions

Supported by the four subsystem managers

SPRING 2011 - 102

12

O PERATING S YSTEM S OFTWARE


( CONTINUED )

Each manager:

Works closely with other managers


Performs a unique role

Manager tasks

Monitor its resources continuously


Enforce policies determining:

Who gets what, when, and how much

Allocate the resource (when appropriate) De-allocate the resource (when appropriate) Resources: CPU time, memory, files, I/O
SPRING 2011 - 102

13

SPRING 2011 - 102

14

M AIN M EMORY M ANAGEMENT

In charge of main memory

Random Access Memory (RAM)

Responsibilities include:

Preserving space in main memory occupied by operating system Checking validity and legality of memory space request Setting up memory tracking table

Tracks usage of memory

Deallocating memory to reclaim it


SPRING 2011 - 102

15

P ROCESSOR M ANAGEMENT

In charge of allocating Central Processing Unit (CPU) Tracks process status

An instance of program execution

Two levels of responsibility:

Handle jobs as they enter the system

Handled by Job Scheduler

Manage each process within those jobs

Handled by Process Scheduler

SPRING 2011 - 102

16

D EVICE M ANAGEMENT

In charge of monitoring all resources

Devices, channels, and control units

Responsibilities include:

Choosing most efficient resource allocation method


Printers, ports, disk drives, etc. Based on scheduling policy

Allocating the device Starting device operation De allocating the device


SPRING 2011 - 102

17

F ILE M ANAGEMENT

In charge of tracking every file in the system

Data files, program files, compilers, application programs

Responsibilities include:

Enforcing user/program resource access restrictions

Uses predetermined access policies


Read-only, read-write, create, delete

Controlling user/program modification restrictions

Allocating resource

Opening the file


De allocating file (by closing it)

SPRING 2011 - 102

C OMPUTER S YSTEM O RGANIZATION

18

SPRING 2011 - 102

19

C OMPUTER S TARTUP

bootstrap program is loaded at power-up or reboot

Typically stored in ROM or EEPROM, generally known as firmware

Initializes all aspects of system

Loads operating system kernel and starts execution

SPRING 2011 - 102

20

C OMPUTER S YSTEM S TRUCTURE


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, compilers, web browsers, database systems, video games People, machines, other computers
SPRING 2011 - 102

Users

21

A B RIEF D ESCRIPTION OF M ACHINE H ARDWARE

Hardware: physical machine and electronic components

memory

Data/Instruction storage

Input / Output devices (I/O devices)


All peripheral devices in system Printers, disk drives, CD/DVD drives, flash memory, and keyboards

Central processing unit (CPU)


Controls interpretation and execution of instructions


Controls operation of computer system
SPRING 2011 - 102

22

A B RIEF D ESCRIPTION OF M ACHINE H ARDWARE ( CONTINUED )

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

SPRING 2011 - 102

23

A B RIEF D ESCRIPTION OF M ACHINE H ARDWARE( CONTINUED )


The concepts of a device really has two parts.

DEVICE

There is the hardware unit which is connected to the machine, and there is the logical device which is a name given by the OS to a legal entry point for talking to a hardware-device.
When a user writes to a logical device, the OS invokes a device driver which performs the physical operations of controlling the hardware.

For example, when writing to a disk, the OS must control the movement of the read-write heads. When writing to a printer, the OS places the information in a queue and services the request when the printer becomes free. Some common logical devices are: the system disks, the keyboard, the screen, the printer and the audio device.

Disks and tapes are often called secondary memory or S 2011 - 102 secondary storage
PRING

24

SPRING 2011 - 102

25

I NTERRUPTS

Interrupt are central to operating systems, as they provide an efficient way for the operating system to interact with and react to its environment The occurrence of an event is usually signaled from either the hardware or the software. Interrupts are hardware signals which are sent to the CPU by the devices it is connected to. These signals literally interrupt the CPU from what it is doing and demand that it spend a few clock cycles servicing a request

Software may trigger an interrupt by executing a special operation called a system call.
SPRING 2011 - 102

26

I NTERRUPTS
,
Interrupts may come from the keyboard because a user pressed a key. Then the CPU must stop what it is doing and read the keyboard, place the key value into a buffer for later For example reading, and return to what it was doing.

The system clock sends interrupts at periodic intervals.


For example

Answer the Phone


. . .

For example

Disk devices generate interrupts when they have finished an I/O task

Resume

SPRING 2011 - 102

27

I NTERRUPTS , T RAPS , AND S IGNALS

Trap

A trap is usually initiated by the CPU hardware. When ever the trap condition occurs (on arithmetic overflow, for example) OR A process can generate a trap, for example, by dividing a number by zero.

Signal

A signal is a limited form of inter-process communication. A user or a process may generate a signal (an interrupt to a process). When a signal is sent to a process, the operating system interrupts the process's normal flow of execution.
SPRING 2011 - 102

O PERATING -S YSTEM O PERATIONS

28

SPRING 2011 - 102

29

D UAL -M ODE O PERATION

Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.
Provide hardware support to differentiate between at least two modes of operations.

User mode execution done on behalf of a user. Monitor mode (also kernel mode or system mode) execution done on behalf of operating system.

SPRING 2011 - 102

30

D UAL -M ODE O PERATION

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.
Some instructions

designated as privileged, only executable

in kernel mode
System call changes mode to kernel, return from call resets

it to user

Interrupt/fault

monitor set user mode

user
SPRING 2011 - 102

31

U SER M ODE AND K ERNEL /M ONITOR M ODE


Kernel Mode User Mode

In this mode software has a complete access to all the hardware and can execute any instruction the machine is capable of executing

The rest of software runs in the user mode in which only a subset of machine instruction is available

SPRING 2011 - 102

32

User Mode

System Call

Signal

Kernal Mode User Mode User Mode

Interrupt
User Mode

Trap

E NTRY P OINTS INTO K ERNEL


SPRING 2011 - 102

33

T RANSITION FROM U SER TO K ERNEL M ODE

SPRING 2011 - 102

34

NOT INCLUDED

SPRING 2011 - 102

35

T HE T RAP I NSTRUCTION O PERATION

When trap occurred the CPU stops what it's doing, saves the context, jumps to the appropriate trap routine, completes it, restores the context, and continues execution.

SPRING 2011 - 102

36

Mode
S 1 trap 2

Branch Table

Trusted Code

User

Supervisor
SPRING 2011 - 102

37

T HE I NTERRUPTS I NSTRUCTION O PERATION

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

Interrupt architecture must save the address of the instruction after the interrupted instruction and the CPU state so that execution of the interrupted process may continue after the interrupt has been

SPRING 2011 - 102

38

SPRING 2011 - 102

C OMPUTER S YSTEM A RCHITECTURE

39

SPRING 2011 - 102

40

S INGLE P ROCESSOR S YSTEMS

Personal computers computer system dedicated to a single user. Interactive User convenience and responsiveness. Can adopt technology developed for larger operating systemsmulti-process, multi-user May run several different types of operating systems (Windows, MacOS, UNIX, Linux)

SPRING 2011 - 102

O PERATING SYSTEM S TRUCTURE

41

SPRING 2011 - 102

42

M ULTIPROGRAMMING

SPRING 2011 - 102

43

Machine Pi

OS Resource Sharing

Pi Memory Pk Memory

Time-multiplexed Physical Processor


Pj Memory

Space-multiplexed Physical Memory


SPRING 2011 - 102

44

M ULTIPROGRAMMING

A single user cannot keep CPU and I/O devices busy at all times. Multiprogramming offers a more efficient approach to increase system performance.
Several jobs are kept in main memory at the same time and the CPU is multiplexed among

SPRING 2011 - 102

45

H OW M ULTIPROGRAMMING W ORKS

Process 1 Process 2 Process 3


Time-multiplexed CPU

Process 4

Space-multiplexed Memory
SPRING 2011 - 102

46

M ULTIPROGRAMMING

SPRING 2011 - 102

47

T IME S HARING / MULTI TASKING

SPRING 2011 - 102

48

T IME S HARING

Time-sharing is the sharing of a computing resource among many users by means of multiprogramming
Time sharing, in which each user has an online terminal.

In Timesharing System, each user is given a time slice/quantum. The user program/process executes for a short time before it either finishes or needs to perform I/O. the resources are then taken away from the user and given to some one else.

SPRING 2011 - 102

49

T IMESHARING S YSTEMS
Abstract Machines Result
Command

Physical Machine

Result
Command

Result
Command
SPRING 2011 - 102

Potrebbero piacerti anche