20
Processes Introduction to Operating Systems: Module 3

Processes

Embed Size (px)

DESCRIPTION

Introduction to Operating Systems: Module 3. Processes. System Calls. System calls provide the interface between a running program and the operating system Generally available as assembly-language (trap) instructions - PowerPoint PPT Presentation

Citation preview

Page 1: Processes

Processes

Introduction to Operating Systems: Module 3

Page 2: Processes

System Calls

System calls provide the interface between a running program and the operating system Generally available as assembly-language (trap) instructions Languages defined to replace assembly language for systems

programming allow system calls to be made directly

Methods used to pass parameters to 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 3: Processes

System Design Goals

User goals – operating system should be convenient to use, easy to learn, reliable, safe, fair, and fast

System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient System goals and user goals may conflict

efficiency vs. fairness easy vs. flexible

Page 4: Processes

System Structure – Layered Approach

The operating system is divided into a number of layers or levels, each built on top of lower layers. The lowest layer is the hardware; the highest is the user interface.

Layers are selected such that each uses functions and services of only lower-level layers.

Page 5: Processes

An Operating System Layer

Functions implemented at layer M

layer M

layer M -1

Functions hidden by layer M

Functions passed by layer M

Page 6: Processes

Monolithic vs. Microkernel OS Monolithic

Every thing resides in the kernel process and memory management Interrupts, I/O, device drivers, file

systems Networking Other functions and system calls

The Kernel is big Everything is part of every

application's address space

Process in a monolithic OS

OS KERNELProcess mngmtMemory mngmt

I/OFile systemsNetworkingInterrupts

All system calls

App1 code

Shared Libraries

App1 Stack

App1 data

Not used

BIG

Page 7: Processes

Monolithic vs. Microkernel OS

Microkernel The kernel contains code for the most basic OS services All other OS services are provided by separate processes

running in user space Can modify components while system is running, don’t need

to recompile to change a driver or other component kernel, drivers export function tables to each other so they can

interact

Microkernel

Client

Microkernel

File Server

Microkernel

Memory Server

Microkernel

Client

Message from client to server

Page 8: Processes

Mechanisms and Policies

Mechanisms determine how to do something, policies decide what will be done

The separation of policy from mechanism is a very important principle: it allows maximum flexibility if policy decisions are to be changed later

Micro-kernel design supports this separation Easy to replace system components

Monolithic design encourages combined mechanism and policy at a low level

Page 9: Processes

Unix System Structure

The UNIX OS consists of two 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 OS functions

Page 10: Processes

Windows Architecture

Interaction among executive components similar to a microkernel system But not all components run as user level services

Executive components communicate by passing messages through a component called the kernel

Hardware abstraction layer (HAL) maps generic hardware interaction to specific platforms. HAL isolates the kernel from architecture-specific details.

Page 11: Processes

Windows Architecture

Page 12: Processes

What is a Process A program in execution A sequentially executing piece of code that runs on one processing

unit of the system An asynchronous computational activity

(i.e., it proceeds at its own pace, independent of another process) The locus of control of a program in execution A process is:

an encapsulation of program, data, resources and a virtual processor controlled and supported by the underlying OS kernel Which can interact with other processes and I/O devices through the OS kernel

Page 13: Processes

The System View of Processes

Processes are an abstraction The computer hardware executes instruction Instructions are grouped into multiple programs in

execution by software constructs Processes do not exist when the computer starts

The instructions initially run set up the data structures needed to implement the process abstraction

The operating system is responsible more maintaining the data structures that implement the process model

The OS needs a system that supports exceptions to do this

Page 14: Processes

In the Beginning

Hardware defines a location from which the initial instruction is fetched after system start-up This bootstrap program loads the operating system code

and initializes operating system data Then “real” processes can be created

Though the process abstraction is not yet defined when it runs, the bootstrap program can be viewed as the initial process

Page 15: Processes

Address Space

In the process abstraction, an address space is more than just memory Inter-process communication objects Files Other resources

Any entity which can be referenced by a process is part of its address space

Page 16: Processes

•Program (text)•Data (global variables)•Stack (temporary data)•Heap (dynamic memory)

Inter-processCommunication

File & I/OOperations

System Calls

OS/Kernel

The operating system can handle all interaction between a process and other system entities; each communication requires a system call

Process-OS interaction

Page 17: Processes

•Program (text)•Data (global variables)•Stack (temporary data)•Heap (dynamic memory)

Inter-processCommunication

File & I/OOperations

System Calls

OS/Kernel

The operating system can set up communication channels between a process and other system entities; once the channel is established, further interaction does not require a system call

Process-OS interaction

Page 18: Processes

A UNIX Process

Abstract Machine Environment

ProgramText

Stack

Process Status

Data

Resources

Files

Object instructions

Static variablesTemporary variables

a.out

Page 19: Processes

Listing unix processes

list processes (Solaris 2): ps — my processes, little detail ps -l — my processes, more detail ps -al — all processes, more detail

miller.cs: ps -l

F UID PID PPID %C PRI NI SZ RSS WCHAN S TT TIME COMMAND

8 1004 16628 16626 0 58 20 1724 1200 ??? S pts/103 0:00 -csh

8 1004 16780 16628 3 58 20 1264 724 ??? S pts/103 0:03 find /

8 1004 16884 16882 0 58 20 1724 1200 ??? S pts/108 0:00 -csh

Page 20: Processes

Process states

terminated

ready

waiting

running terminate

block

dispatch

pre-empt

wakeup

inactive

create

activate

suspend