Presentation is loading. Please wait.

Presentation is loading. Please wait.

PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS.

Similar presentations


Presentation on theme: "PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS."— Presentation transcript:

1 PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS

2 DEFINITION: PROCESS Program in execution Current value of program counter Values of registers Values of variables

3 THE PROCESS MODEL (1) Four Independently Scheduled Processes

4 THE PROCESS MODEL (2) Only one program is active at once.

5 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

6 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.

7 EXAMPLE Process A pty 1 waiting for keyboard input Process B pty 2 waiting for printer Process C pty 3 waiting for disk input Where 3 is highest If Process A gets input before C gets input, we shouldn’t hold process A

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

9 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)

10 RUNNING TO READY Process exhausts quantum Clock generates an interrupt o/s dispatches highest priority ready process

11 RUNNING TO BLOCKED Running process does i/o op Blocks itself

12 BLOCKED TO READY Event for which process was waiting completes Process is added to priority queue

13 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

14 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

15 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

16 EXAMPLE: WAIT int* status int 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

17 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 = p n So, the probability that the cpu is used = 1 – p n

18 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.


Download ppt "PROCESSES TANNENBAUM, SECTION 2-1 OPERATING SYSTEMS."

Similar presentations


Ads by Google