+ All Categories
Home > Documents > PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

Date post: 13-Jan-2016
Category:
Upload: shanna-floyd
View: 231 times
Download: 0 times
Share this document with a friend
Popular Tags:
18
PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS
Transcript
Page 1: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

PROCESSESTANNENBAUM, SECTION 2-1

OPERATING SYSTEMS

Page 2: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

DEFINITION: PROCESS

• Program in execution• Current value of program counter• Values of registers• Values of variables

Page 3: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

THE PROCESS MODEL (1)

Four Independently Scheduled Processes

Page 4: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

THE PROCESS MODEL (2)

Only one program is active at once.

Page 5: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

STATES

• Processes go through a series of discrete states• Running State• Process currently has cpu

• Ready state• Could use cpu if one were available

• Blocked state• Waiting for some event to happen, say i/o completion

Page 6: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

LISTS

• Assume a single CPU system• 1 process can run at a time• Several process may be ready• Several processes may be blocked

• Two Lists• Priority queue of ready processes• Unordered list of blocked processes• Unordered because processes become unblocked in the order

in which the resources they require become available.

Page 7: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

EXAMPLE

• Process A pty 1 waiting for keyboard input• Process B pty 2 waiting for printer• Process C pty 3 waiting for disk inputWhere 3 is highestIf Process A gets input before C gets input, we

shouldn’t hold process A

Page 8: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

STATES (2)

Tanenbaum & Bo,Modern Operating Systems:4th ed., (c) 2013 Prentice-Hall, Inc. All rights reserved.

Page 9: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

READY TO RUNNING

• Job is admitted to system• Process created and placed in ready queue• Gradually makes its way to the head of the queue• When CPU is available, scheduled (dispatched)

Page 10: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

RUNNING TO READY

• Process exhausts quantum• Clock generates an interrupt• o/s dispatches highest priority ready process

Page 11: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

RUNNING TO BLOCKED

• Running process does i/o op• Blocks itself

Page 12: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

BLOCKED TO READY

• Event for which process was waiting completes• Process is added to priority queue

Page 13: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

PROCESS TABLE

• Every O/S has a process table• 1 entry per process, called the PCB• PCB is a record (struct)• Process table is an array of pointers to structs• Each process is uniquely identified by its PCB

Page 14: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

PROCESS CONTROL BLOCK

• PCB is what defines a process to the system• Current state of the process (running, ready,

blocked)• Unique id of the process• Pointer to the process’ parent• Pointer to each child process• Process’ priority• Pointer to process’ memory• Pointer to allocated resources (printers, disk drives,

unacknowledged messages)• Register save area• File descriptors• Processor that process is running on

Page 15: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

EXAMPLE: FORK

int fork()• Returns• -1: no process was created• 0: returned to the child process• pid: returned to parent process

• Creates• Copy of parent process but with its own pid and a

different parent pid

Page 16: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

EXAMPLE: WAIT

• int* statusint wait(status)• Suspends calling process until it receives a signal

to wakeup• Returns (in the case of a fork)• pid of child• -1 if childless

• See example 10 on the website

Page 17: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

MODELING MULTIPROGRAMMING

• Suppose a process spends a fraction, p, of its time waiting for i/o.• That is, at any randomly chosen time, the

probability that the process is blocked waiting for i/o is p.• With n processes, the probability that all

are waiting for i/o = pn

• So, the probability that the cpu is used = 1 – pn

Page 18: PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

MODELING MULTIPROGRAMMING (2)

CPU use as a function of the number of processes in memory (i.e., n). As prob. of i/o blocking increases, cpu use increases with more processes. Of course, the more memory, the more processes.


Recommended