240-323, part ii processes

22
240-323 OS,2000 1 240-323, Part II Processes epartment of Computer Engineering, PSU Wannarat Suntiamorntu

Upload: farrah-galloway

Post on 31-Dec-2015

20 views

Category:

Documents


3 download

DESCRIPTION

Department of Computer Engineering, PSUWannarat Suntiamorntut. 240-323, Part II Processes. Department of Computer Engineering, PSUWannarat Suntiamorntut. Process Concept. Department of Computer Engineering, PSUWannarat Suntiamorntut. Process State Transitions. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: 240-323, Part II  Processes

240-323 OS,2000

1

240-323, Part II Processes

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Page 2: 240-323, Part II  Processes

240-323 OS,2000

2

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process Concept

Page 3: 240-323, Part II  Processes

240-323 OS,2000

3

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process State Transitions

Page 4: 240-323, Part II  Processes

240-323 OS,2000

4

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process State

Page 5: 240-323, Part II  Processes

240-323 OS,2000

5

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process control block (PCB)

• Stores all of information about a process• Processes (PCBs) are manipulated by two main components of the process subsystem in order to achieve the effects of multiprogramming:

Scheduler: determines the order by which processes will gain access to the CPU. Efficiency and fair-play are issues here.Dispatcher: actually allocates CPU to process next in line as determined by the scheduler.

Page 6: 240-323, Part II  Processes

240-323 OS,2000

6

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process control block (PCB)

pointer Process state

Process number

Program counter

Registers

Memory limits

List of open files

...

Page 7: 240-323, Part II  Processes

240-323 OS,2000

7

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process control block (PCB)

• Process status (or state): new, ready to run, user running, kernel running, waiting, halted• Program counter: where in program the process is executing• CPU registers: contents of general-purpose register stack pointer, PSW, index registers• Memory Management info: segment base and limit registers, page table, location of pages on disk, process size• User ID, Group ID, Process ID, Parent PID, ...• Event Descriptor: when process is in the “sleep” or waiting state• Scheduling info: process priority, size of CPU quantum, length of current CPU burst

Page 8: 240-323, Part II  Processes

240-323 OS,2000

8

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process scheduling

Scheduling queues

Page 9: 240-323, Part II  Processes

240-323 OS,2000

9

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Schedulers

Process scheduling

• select process• long-term scheduler (job scheduler) selects processesfrom the pool and loads them into memory for execution.• Short-term scheduler(cpu scheduler) selects processesfrom among the processes that are ready to execute andallocates the CPU to one of them.

Page 10: 240-323, Part II  Processes

240-323 OS,2000

10

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process Priority

Page 11: 240-323, Part II  Processes

240-323 OS,2000

11

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Context Switch

• Switch the CPU to another process • speed varied from machine to machine• context-switch times are depended on hardware support

Page 12: 240-323, Part II  Processes

240-323 OS,2000

12

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Multiprogramming to Context Switch

executing

process A process B

i/o request, timeout, ...waiting

save A’s state

restore B’s statedispatch

save B’s state

restore A’s state

Page 13: 240-323, Part II  Processes

240-323 OS,2000

13

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Forking a new process

Page 14: 240-323, Part II  Processes

240-323 OS,2000

14

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process terminate

Page 15: 240-323, Part II  Processes

240-323 OS,2000

15

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Process terminate

Page 16: 240-323, Part II  Processes

240-323 OS,2000

16

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Concurrent Process

• Implementing a multiprogramming OS requires programming to accommodate a number of simultaneously executing processes

• Multiple-process paradigm also useful for applications (e.g., parallel processing, background processing)

• Two kinds of parallelism in today's computer systems:

– Pseudo-parallelism - one CPU supports multiple processes

– True parallelism - processes run on multiple CPUs

Page 17: 240-323, Part II  Processes

240-323 OS,2000

17

Department of Computer Engineering, PSU Wannarat Suntiamorntut

• Two kinds of communication paradigms:- Shared-variable model- Message-passing model

• Most systems incorporate a mixture of the two.

Concurrent Process

Page 18: 240-323, Part II  Processes

240-323 OS,2000

18

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Interprocess Communication (IPC)

Page 19: 240-323, Part II  Processes

240-323 OS,2000

19

Department of Computer Engineering, PSU Wannarat Suntiamorntut

How are links established?

• Direct communicationsend(process_id, message)

receive(process_id, message)

Example : producer and consumer problem

Page 20: 240-323, Part II  Processes

240-323 OS,2000

20

Department of Computer Engineering, PSU Wannarat Suntiamorntut

Direct communication

Process : producer repeat

...Produce an item in nextp...Send(consumer,nextp);...

until false;

Process : consumer repeat

receive(producer,nextc);...

Consume the item in nextc...

until false;

This is a symmetry in addressing

Page 21: 240-323, Part II  Processes

240-323 OS,2000

21

Department of Computer Engineering, PSU Wannarat Suntiamorntut

• Indirect Communicationsend(mailbox, message)

receive(mailbox, message)

How are links established?

- Associate with more than two processes.

mbox

PR

Q

Page 22: 240-323, Part II  Processes

240-323 OS,2000

22

Department of Computer Engineering, PSU Wannarat Suntiamorntut

What’s the capacity of the links?

• Buffering : three ways to implement queue- Zero capacity - Bounded capacity- Unbounded capacity

A “zero-capacity” buffer means processes must “handshake”in order to communicate.