os

56
SUSHMA RAWAL 1 OPERATING SYSTEM

description

A brief intro of operating systems

Transcript of os

Page 1: os

SUSHMA RAWAL 1

OPERATING SYSTEM

Page 2: os

SUSHMA RAWAL 2

Components of a computer system

Page 3: os

SUSHMA RAWAL 3

Components of a computer system

Hardware – provides basic computing resources

• CPU, memory, I/O devices

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

Users

• People, machines

Operating system

• Controls and coordinates use of hardware among various applications and users

Page 4: os

SUSHMA RAWAL 4

Operating System

Operating System

• is a program that manages the computer

hardware.

• Provides basis for application programs

• acts as an intermediary between the user

and computer hardware.

Page 5: os

SUSHMA RAWAL 5

Operating System

Goals of OS

• Efficient use of computer system when

shared by many users.

• User convenience - PC.

Page 6: os

SUSHMA RAWAL 6

Operating System

• Operating System controls the execution of

application programs and coordinates the

use of the hardware among various

application programs for various users.

Page 7: os

SUSHMA RAWAL 7

Operating System

OS can be viewed as

• Resource Allocator-

- Manages all resources

i.e CPU time, memory space, file-storage space,

I/O devices etc.

- Decides between conflicting requests for

efficient and fair resource use

• Control program- Manages execution of programs to prevent errors. It is concerned with operation and control of I/O devices

Page 8: os

SUSHMA RAWAL 8

Defining operating systems

• Goal of computer systems is to execute user

programs and to make solving user

problems easier.

• Therefore computer hardware is constructed

and application programs are developed.

• The common functions of controlling and

allocating resources are then brought

together into one piece of software : OS

Page 9: os

SUSHMA RAWAL 9

Computer System Organization

• Computer-system

– CPU, device controllers connect through

common bus providing access to shared

memory

– Concurrent execution of CPUs and devices

competing for memory cycles

Page 10: os

SUSHMA RAWAL 10

Computer System Organization

Page 11: os

SUSHMA RAWAL 11

Computer Startup

• bootstrap program is loaded at power-up

or reboot

– Typically stored in ROM or EEPROM,

generally known as firmware

– Initializes all aspects of system from CPU

registers to device controllers

– Loads operating system kernel

Page 12: os

SUSHMA RAWAL 12

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

Page 13: os

SUSHMA RAWAL 13

Common Functions of Interrupts

• The occurrence of an event is signaled by an interrupt.

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

Page 14: os

SUSHMA RAWAL 14

Common Functions of Interrupts

• A trap is a software-generated interrupt

caused either by an error or a user request.

• An operating system is interrupt driven.

Page 15: os

SUSHMA RAWAL 15

Structure of an OS

• Kernel

• Non kernel programs

• User interface

Page 16: os

SUSHMA RAWAL 16

Structure of an OS

Kernel

- core of the OS

- controls the operation of the computer

- provides a set of functions and services to

use the CPU and resources of the computer.

Page 17: os

SUSHMA RAWAL 17

Structure of an OS

• Non-kernel programs

- implement user commands

- they use the facilities provided by kernel

programs to interact with the hardware.

Page 18: os

SUSHMA RAWAL 18

Structure of an OS

• Programs in the user interface

- provide a command line interface or GUI

to the user.

- these programs use the facilities of the

non-kernel programs.

- user interacts with the programs in the

user interface to request use of resources

and services provided by the system

Page 19: os

SUSHMA RAWAL 19

Operating-System Structures

• System Components

• Operating System Services

• System Calls

• System Programs

• System Structure

Page 20: os

SUSHMA RAWAL 20

System Components

• Process Management

• Main Memory Management

• File Management

• I/O System Management

• Secondary Memory Management

• Networking

• Protection System

• Command-Interpreter System

Page 21: os

SUSHMA RAWAL 21

Process Management

• A process is a program in execution.

• A process needs certain resources: 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

Page 22: os

SUSHMA RAWAL 22

Main-Memory Management

• Memory is a large array of bytes, each with its own address.

• Main memory 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 andby whom.

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

– Allocate and deallocate memory space as needed.

Page 23: os

SUSHMA RAWAL 23

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.

- File backup on stable (nonvolatile) storage media.

Page 24: os

SUSHMA RAWAL 24

I/O System Management

• Operating system hides the peculiarities of

specific hardware devices from the user.

• The I/O system consists of:

– A buffer system

– A general device-driver interface

– Drivers for specific hardware devices

Page 25: os

SUSHMA RAWAL 25

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

Page 26: os

SUSHMA RAWAL 26

Networking (Distributed Systems)

• A distributed system is a collection of

physically separate, possibly heterogeneous

computer systems that are networked to

provide the users with access to various

resources that the system maintains.

• The processors in the system are connected

through a communication network.

Page 27: os

SUSHMA RAWAL 27

Networking (Distributed Systems)

• Communication takes place using a

protocol.

• A distributed system provides user access to

various system resources.

• Access to a shared resource allows:

– Computation speed-up

– Increased functionality

– Increased data availability

Page 28: os

SUSHMA RAWAL 28

Protection System

• Protection refers to a mechanism for

controlling access of programs, processes,

or users to resources.

• The protection mechanism must:

– distinguish between authorized and

unauthorized usage.

– specify the controls to be imposed.

– provide a means of enforcement.

Page 29: os

SUSHMA RAWAL 29

Command-Interpreter System

• An important systems programs for OS is command interpreter.

• It is an interface between user and the OS.

• 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

Page 30: os

SUSHMA RAWAL 30

Command-Interpreter System (Cont.)

• The program that reads and interprets

control statements is called variously:

-command-line interpreter

– shell (in UNIX)

• Its function is to get and execute the next

command statement.

Page 31: os

SUSHMA RAWAL 31

Operating System Services

• Program execution – system capability to

load a program into memory and to run it.

• I/O operations – for protection and

efficiency, user programs cannot control I/O

devices directly, the operating system must

provide some means to perform I/O.

• File-system manipulation – program

capability to read, write, create, and delete

files.

Page 32: os

SUSHMA RAWAL 32

Operating System Services

• 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 and consistent

computing by detecting errors in the CPU and

memory hardware, in I/O devices, or in user

programs by taking appropriate action.

Page 33: os

SUSHMA RAWAL 33

Additional Operating System Functions

Additional functions 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.

Page 34: os

SUSHMA RAWAL 34

System Calls

• System calls provide an interface to the

services made available by 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++)

Page 35: os

SUSHMA RAWAL 35

System Calls

• Parameters need to be passed for some of the

system calls

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

Page 36: os

SUSHMA RAWAL 36

Passing of Parameters As A Table

Page 37: os

SUSHMA RAWAL 37

Types of System Calls

• Process control

• File management

• Device management

• Information maintenance

• Communications

Page 38: os

SUSHMA RAWAL 38

Types of System Calls

Process control

• Create process, terminate process

• Get process attributes, set process attributes

• Wait event, signal event

• Wait for time

• End , abort

Page 39: os

SUSHMA RAWAL 39

Types of System Calls

File management

• Create file, delete file

• Open, close

• Read, write

• Get file attributes, set file attributes

Page 40: os

SUSHMA RAWAL 40

Types of System Calls

Device management

• Request device, release device

• Read, write

• Get file attributes, set file attributes

• Logically attach or detach devices

Page 41: os

SUSHMA RAWAL 41

Types of System Calls

Information maintenance

• Get time or date, set time or date

• Get system data, set system data

• Get process file, or device attributes

• Set process file, or device attributes

Page 42: os

SUSHMA RAWAL 42

Types of System Calls

Communications

• Create, delete communication connection

• Send, receive messages

• Transfer status information

• Attach or detach remote devices.

Page 43: os

SUSHMA RAWAL 43

System Programs

• System programs/system utilities provide a convenient environment for program development and execution.

• They can be divided into:– File manipulation

– Status information

– File modification

– Programming language support

– Program loading and execution

– Communications

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

Page 44: os

SUSHMA RAWAL 44

UNIX System Structure

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

Page 45: os

SUSHMA RAWAL 45

UNIX System Structure

Page 46: os

SUSHMA RAWAL 46

UNIX System Structure

• Unix system structure was monolithic structure.

• Large amount of functionality was combined into

one level

• It was difficult to implement and maintain.

Page 47: os

SUSHMA RAWAL 47

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.

Page 48: os

SUSHMA RAWAL 48

An Operating System Layer

Page 49: os

SUSHMA RAWAL 49

Kernel Space and User Space

� The program code corresponding to the kernel

applications/services are kept in a contiguous area (OS

dependent) of primary (working) memory and is protected

from the un-authorized access by user

programs/applications

� The memory space at which the kernel code is located is

known as ‘Kernel Space’

� All user applications are loaded to a specific area of

primary memory and this memory area is referred as ‘User

Space’

Page 50: os

SUSHMA RAWAL 50

Kernel Space and User Space

� The partitioning of memory into kernel and user space is

purely Operating System dependent

� Most of the operating systems keep the kernel application

code in main memory and it is not swapped out into the

secondary memory

Page 51: os

SUSHMA RAWAL 51

Monolithic Kernel

� All kernel services run in the kernel space

� All kernel modules run within the same memory space

under a single kernel thread

� The tight internal integration of kernel modules in

monolithic kernel architecture allows the effective

utilization of the low-level features of the underlying

system

� The major drawback of monolithic kernel is that any error

or failure in any one of the kernel modules leads to the

crashing of the entire kernel application

� LINUX, SOLARIS, MS-DOS kernels are examples of

monolithic kernel

Page 52: os

SUSHMA RAWAL 52

Monolithic Kernel

Monolithic kernel with all

operating system services

running in kernel space

Applications

Page 53: os

SUSHMA RAWAL 53

Microkernel

� The microkernel design incorporates only the essential set

of Operating System services into the kernel

� Rest of the Operating System services are implemented in

programs known as ‘Servers’ which runs in user space

� All servers are kept separate and run in different address

spaces

� The kernel design is highly modular and provides OS-

neutral abstraction

� Memory management, process management, timer systems

and interrupt handlers are examples of essential services,

which forms the part of the microkernel

Page 54: os

SUSHMA RAWAL 54

Microkernel

� The communication in microkernels is done via message

passing.

� The servers communicate through IPC (Interprocess

Communication).

� Servers invoke "services" from each other by sending

messages.

� Mach, QNX, Minix 3, windows NT kernels are examples

for microkernel

Page 55: os

SUSHMA RAWAL 55

Microkernel

Microkernel with essential

services like memory

management, process

management, timer system etc...

Servers (kernel

services running

in user space) Applications

Page 56: os

SUSHMA RAWAL 56

Microkernel

• Benefits:

- easier to extend a microkernel

- easier to port the operating system to new

architectures

- more reliable (less code is running in

kernel mode)

- more secure