• No results found

lecture 6 chapter 2

N/A
N/A
Protected

Academic year: 2020

Share "lecture 6 chapter 2"

Copied!
35
0
0

Loading.... (view fulltext now)

Full text

(1)

07/10/2020 1

Lecture 6

Chapter 2

Processes and Threads

discover yourself

(2)

1.Processes

2.Threads

3.Inter-Process Communication

(IPC)

4.Scheduling

Contents

discover yourself

(3)

07/10/2020 3

Processes

Processes

Difference between Process and Program

Program

A set of instruction to solve the problem.

Process

A program in execution.

discover yourself

(4)

Processes

Processes

Difference between Process and Program

Baking a Birthday Cake

1- Baker - A person who will bake the cake 2- Recipe – Method to bake the cake

3- Ingredients – Inputs/things to bake the cake

Here baker acts as a processor (CPU)  Recipe acts as a program

 Ingredients acts as an input data

So, process is an activity consisting of our baker reading the recipe, fetching the ingredients and baking the cake.

discover yourself

(5)

07/10/2020 5

The Process Model The Process Model

4 programs in the

memory Only one program is active at once

In Process model, all software on the computer is organized into a number of sequential processes. A process includes PC, registers, and variables. In reality, the CPU switches back and forth among processes. (The rapid switching back and forth is called multiprogramming).

discover yourself

(6)

Process Creation – System Initialization Process Creation – System Initialization

1. Foreground processes

Interact with users and perform work for them

2. Background processes

Not associated with users but have some specific functions.

discover yourself

(7)

07/10/2020 7

Process Creation

Process Creation

Principal events that cause process creation

1.

System initialization

2.

Execution of a process creation system

3.

User request to create a new process

4.

Initiation of a batch job

discover yourself

(8)

Process Creation – System Initialization Process Creation – System Initialization

Background processes in XP &

discover yourself

(9)

07/10/2020 9 Process Creation – System Initialization

Process Creation – System Initialization

Foreground

Processes

discover yourself

(10)

Process Creation – System Initialization Process Creation – System Initialization

discover yourself

(11)

07/10/2020 11

Process Creation – Execution of a process creation system call Process Creation – Execution of a process creation system call

Running process will issue some system calls to create one or more new processes.

e.g. Large amount of data fetched over a network. User requests of a file be printed.

discover yourself

(12)

Process Creation – a user request to create a new process Process Creation – a user request to create a new process

These actions starts a new process and runs the selected programs in it.

discover yourself

(13)

07/10/2020 13 Process Creation – Batch system process

Process Creation – Batch system process

discover yourself

(14)

Process Creation – Batch system process Process Creation – Batch system process

discover yourself

(15)

07/10/2020 15 Process Creation – Batch system process

Process Creation – Batch system process

discover yourself

(16)

Process Termination Process Termination

Conditions which terminate processes

1. Normal exit

2. Error exit

3. Fatal error

4. Killed by another process

discover yourself

(17)

07/10/2020 17

Process Termination Process Termination

Normal Exit

1. Processes terminate because they have done their work.

This is called normal exit.

2. e.g. Compiler compile the program. This call is EXIT in

UNIX and EXIT process in Windows.

discover yourself

(18)

Process Termination – Normal Exit Process Termination – Normal Exit

Example how process is terminated in Windows environment

discover yourself

(19)

07/10/2020 19 Process Termination – Normal Exit

Process Termination – Normal Exit

discover yourself

(20)

Process Termination – Normal Exit Process Termination – Normal Exit

discover yourself

(21)

07/10/2020 21

Process Termination – Error Exit Process Termination – Error Exit

Process terminates when error is introduced in it.

If user types the command

cc prog1.c

to compile the program prog1.c and no such file exists, the

compiler simply exits.

discover yourself

(22)

Process Termination – Error Exit Process Termination – Error Exit

Disk Operating System (DOS)

discover yourself

(23)

07/10/2020 23

Process Termination – Error Exit Process Termination – Error Exit

Windows Environment

discover yourself

(24)

Process Termination – Error Exit Process Termination – Error Exit

Windows Environment

discover yourself

(25)

07/10/2020 25

Process Termination – Fatal Error Process Termination – Fatal Error

In computing, a fatal error or fatal exception error is an error that causes a program to abort and may therefore return the user to the operating system. When this happens, data that the program was processing may be lost. This is an error caused by the process,

often due to the program bug.

e.g.

1.Executing an illegal instruction

2.Referencing non-existent memory location

3.Dividing the number by ZERO. (Executio

n Error)

discover yourself

(26)

Process Termination – Fatal Error Process Termination – Fatal Error

discover yourself

(27)

07/10/2020 27

Process Termination – Fatal Error Process Termination – Fatal Error

discover yourself

(28)

Process Termination – Fatal Error Process Termination – Fatal Error

discover yourself

(29)

07/10/2020 29

Process Termination – Killed by another process Process Termination – Killed by another process

1. Process executes a system call telling the OS to kill

some other process. In UNIX this call is KILL and

TERMINATE process in Windows.

discover yourself

(30)

Two States Transition Diagram

discover yourself

(31)

07/10/2020 31

Five States Process Model

Running

The process that is currently being executed

Ready

A process that is prepare to execute when given the opportunity

Blocked

A process that cannot execute until some event occur, such as I/O operations.

New

A process that has just been created

Exit

A process that has been released from the pool of executable processes by the OS

discover yourself

(32)

Five States Process Model

discover yourself

inspire posterity

New Ready Running Exit

Blocked Admit

Event Occurs

Dispatch Release

Time-out

(33)

07/10/2020 33

discover yourself

inspire posterity

Single Blocked Queue

(34)

discover yourself

inspire posterity

Admit Ready Queue Dispatch Time-out Release Processor

Event 1 Wait

Event 1 Queue Event 1

Occurs

Event 2 Wait Event 2

Occurs

(35)

07/10/2020 35 New Ready: The OS will move a process from new state to the ready state

Ready Running: The OS will choose one of the process from the ready state. This is the job of dispatcher or scheduler.

Running Exit: The running process is terminated by the OS, if the process indicates that it has completed his job.

Running Ready: When running process has reached max. allowable time.

Running Blocked: A process is put in the blocked state if it requests something i.e. request a resource such as file, I/O operations.

Blocked Ready: A process in the blocked state is moved to the ready state when the event for which it has been waiting occurs.

discover yourself

References

Related documents

1) Provide a comprehensive account of the implementation and ongoing operation of the NA role in the acute hospital setting, including the examination of policies and procedures

Private Cloud or In House Server WAN LAN Firewall Applications Infrastructure Storage.!.

it sets the per-CPU current process variable proc switches to the process’s page table with switchuvm() marks the process as RUNNING. and then calls swtch() to start

If a store chose revenue- sharing (fixed-fee) terms every time a C title was purchased, the store is not included as an observation in the column containing information on

The constraints of the existing swimming pool building footprint and the priority to maintain the open, unfettered relationship between the building and its parkland setting

the provisions to prepare for and respond to emergency situations and procedures for internal audits and management review. ISM- CODE/Sets 1) a safety and environmental

 Machine: specifies the physical machine that the server is running on and the Node Manager properties; (the Node Manager is a process agent running on the

These along with hundreds of resources found locally and abroad are contained in “The Spa, Massage and Wellness Resource Guide and Career Book”, the first book of resource