23565104 process-management(2)

Post on 11-Nov-2014

1300 Views

Category:

Education

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

Transcript

Module 2

OS RESPONSIBILITIES FOR PROCESS MGMT.

Creating and deleting of process Scheduling of a process (suspending and resuming

the execution of process) Process synchronization Process communication Deadlock handling

WHAT IS A PROCESS? Process

– Program in execution needing resources (such as CPU time, memory, files and I/O devices) to accomplish its tasks.

- Executing set of machine instructions- Execution of a process must progress in a sequential fashion; at

most one instruction is executed on behalf of the process.

COMPONENTS OF A PROCESS Code Data Resources Status Threads

CLASSIFICATION OF OS ACCORDING TO THE TYPES OF SYSTEM: Single-process single-threaded – only one

process can execute at a time. Once a process is allocated to the CPU, that process runs to completion before any other process can execute.

Example: DOS

CLASSIFICATION OF OS ACCORDING TO THE TYPES OF SYSTEM:

Multi-process single threaded – a single entity (the process), is the object upon which both resource allocation and CPU scheduling are performed.

Example: UNIX

CLASSIFICATION OF OS ACCORDING TO THE TYPES OF SYSTEM: Multi-process multi-threaded – resources are

allocated to the processes but CPU scheduling can be in terms of thread.

Example: Windows, Mach, Solaris

IS PROCESS THE SAME AS PROGRAM? No, it is both more and less

More – a program is just part of a process context.

Less – a program may invoke several processes

UNIPROGRAMMING & MULTIPROGRAMMING

Uniprogramming allows execution of only one process at a time (e.g.

personal computer)

Multiprogramming allows more than one process (e.g. concurrent execution

of many processes)

HOW CAN SEVERAL PROCESSES SHARE ONE CPU?

OS takes care of this by making sure that:

Each process gets a chance to run (fair scheduling)

They do not modify each other’s state(protection)

OS EXECUTION

An OS executes a variety of programs: Batch systems Time-shared systems

A PROCESS INCLUDES:

Program counter and contents of processor registers.

Process stack (contains temporary data such as subroutine parameters, return addresses, variables)

Data section (contains global variables) Heap

Memory that is dynamically allocated during run time.

SIX (6) PROCESS STATES:

New Process is being created but not yet included in the pool

of executable processes (resource acquisition) Ready

Waiting to be assigned to the processor Running (or active)

Process that is currently being executed

SIX (6) PROCESS STATES: (CONT)

Waiting (or blocked) Waiting for some event to occur (I/O completion)

Stopped Special case of blocked where the operator/user

suspends the process. Terminated (or exiting)

Process has finished execution. A process is about to be removed from the pool of executable processes.

DIAGRAM OF PROCESS STATE

NewNewReadyReady ActiveActive ExitingExiting

StoppedStopped

BlockedBlocked

create

resume time-out

dispatch

suspendkill

kill

exit

error

Event occurs or resource available

State transition_____ internal_ _ _ _external

PROCESS CONTROL BLOCK (PCB) Each process is represented in the OS by a PCB. It is where collection of process information are kept

and accessed.

Sometimes called the Task Control Block (TCB)

PCB INFORMATION:

Process state Program counter (PC) CPU Registers CPU Scheduling information Memory-Management Information Accounting information I/O status information

PROCESS CONTROL BLOCK

Operations on Processes• Create a process• Destroy a process• Suspend a process• Resume a process• Change the priority of a process• Block a process• Wake up a process• Dispatch a process• Enable interprocess communication

CONTEXT SWITCH When a CPU switches to another process, the system

must save the state of the old process and load the saved state of the new process

Context-switch time is overhead; the system does no useful work during switching.

CONTEXT SWITCH

PROCESS SCHEDULING:

Objective of multiprogramming: have some user process running at all times

OS keeps the CPU busy with productive work by dynamically selecting (scheduling) the next user process to become active.

SCHEDULING QUEUES Job queue

Set of all processes that enter the system Ready queue (linked-list)

Set of all processes residing in main memory, ready and waiting to execute.

Device queues Set of processes waiting for an I/O device, each device

has a device queue.

QUEUING DIAGRAM:

LONG-TERM SCHEDULER (OR JOB SCHEDULER) Selects which processes should be brought into the

ready queue; these processes are spooled to a mass-storage (disk) where they are kept for later execution.

Controls the degree of multiprogramming

LONG TERM SCHEDULER: (CONT) Must make careful selection among the processes (a

good process mix).

Processes can be described as either: I/O bound process – spends more time doing I/O than

computations, may short CPU bursts

CPU bound process – spends more time doing computations, few very long CPU bursts.

SHORT-TERM SCHEDULER

Known as the CPU scheduler.

Selects which process should be executed next and allocates the CPU.

MEDIUM-TERM SCHEDULER (SWAPPER)

Involves suspending or resuming processes by swapping or rolling them out of or into memory.

Swapping Removing a process from the memory.

MEDIUM-TERM SCHEDULER

THREAD: DEFINITION

A basic unit of CPU utilization Comprises a thread ID, program counter,

register set, and a stack. Process types:

Single-threaded – performs one task at a time Multithreaded – performs more than one task at

a time.

EXAMPLES OF THREAD

Web browser One thread – displays images/text Another thread – retrieves data from network

Word processor One thread – displays graphics Another thread – responds to user keystrokes Another thread – performs spelling and grammar

top related