Tải bản đầy đủ (.ppt) (44 trang)

Chapter 3 Processes

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (653.9 KB, 44 trang )


Chapter 3: Processes
Chapter 3: Processes
3.2
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Chapter 3: Processes
Chapter 3: Processes












3.3
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process Concept
Process Concept






Batch system – jobs

Time-shared systems – user programs or tasks

 jobprocess


!"
#



program counter

stack

data section
3.4
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process in Memory
Process in Memory
3.5
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th

Edition, Feb 7, 2006
Process State
Process State

$state

new: The process is being created

running: Instructions are being executed

waiting: The process is waiting for some event to occur

ready: The process is waiting to be assigned to a processor

terminated: The process has finished execution
3.6
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Diagram of Process State
Diagram of Process State
3.7
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process Control Block (PCB)
Process Control Block (PCB)
%






&

&

'



(
3.8
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process Control Block (PCB)
Process Control Block (PCB)
3.9
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
CPU Switch From Process to Process
CPU Switch From Process to Process
3.10
Silberschatz, Galvin and Gagne ©2005

Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process Scheduling Queues
Process Scheduling Queues

Job queue!

Ready queue!
$%

Device queues!%
(

#
3.11
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Ready Queue And Various I/O Device Queues
Ready Queue And Various I/O Device Queues
3.12
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Representation of Process Scheduling
Representation of Process Scheduling
3.13

Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Schedulers
Schedulers

Long-term scheduler)*+!
%
#

Short-term scheduler)&+!
%
&
3.14
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Addition of Medium Term Scheduling
Addition of Medium Term Scheduling
3.15
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Schedulers (Cont.)
Schedulers (Cont.)

 #

)+⇒)+

, #
)$+⇒)%+

degree of
multiprogramming



I/O-bound process – spends more time doing I/O than
computations, many short CPU bursts

CPU-bound process – spends more time doing computations;
few very long CPU bursts
3.16
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Context Switch
Context Switch

-&%$

%

%"
% %%


%
3.17
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process Creation
Process Creation

$%$
$


.

Parent and children share all resources

Children share subset of parent’s resources

Parent and child share no resources

/

Parent and children execute concurrently

Parent waits until children terminate
3.18
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th

Edition, Feb 7, 2006
Process Creation (Cont.)
Process Creation (Cont.)



Child duplicate of parent

Child has a program loaded into it

&01

fork system call creates new process

exec system call used after a fork to replace the process’
memory space with a new program
3.19
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Process Creation
Process Creation
3.20
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
C Program Forking Separate Process
C Program Forking Separate Process

)+
2
3"
(4 4(
5 )+"
)67+2(44(
)$89 98+"
):+"
;
)557+2(44(
)8((8$88$0&,,+"
;
2(44(
(4%%
4(
%)0&,,+"
)88+"
)7+"
;
;
3.21
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
A tree of processes on a typical Solaris
A tree of processes on a typical Solaris
3.22
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7

th
Edition, Feb 7, 2006
Process Termination
Process Termination

 
)exit+

Output data from child to parent (via wait)

Process’ resources are deallocated by operating system


)abort+

Child has exceeded allocated resources

Task assigned to child is no longer required

If parent is exiting

Some operating system do not allow child to continue if its
parent terminates

All children terminated - cascading termination
3.23
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006

Cooperating Processes
Cooperating Processes

Independent<<


Cooperating<<




Information sharing

Computation speed-up

Modularity

Convenience
3.24
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Producer-Consumer Problem
Producer-Consumer Problem

$producer

consumer


unbounded-buffer places no practical limit on the size of the
buffer

bounded-buffer assumes that there is a fixed buffer size
3.25
Silberschatz, Galvin and Gagne ©2005
Operating System Concepts - 7
th
Edition, Feb 7, 2006
Bounded-Buffer – Shared-Memory Solution
Bounded-Buffer – Shared-Memory Solution


#define BUFFER_SIZE 10
typedef struct {
. . .
} item;
item buffer[BUFFER_SIZE];
int in = 0;
int out = 0;

$=&99/.3>/:


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×