• No results found

lecture 7 chapter 2

N/A
N/A
Protected

Academic year: 2020

Share "lecture 7 chapter 2"

Copied!
17
0
0

Loading.... (view fulltext now)

Full text

(1)

Lecture 7

Chapter 2

Processes and Threads

discover yourself

(2)

P1

P2

P3

P4

Processes Swapping

Swapping

consists of bringing each process in

the memory, running it for a while and then putting it back on the disk.”

discover yourself

(3)

1. Memory holds multiple processes and that

the processor can move to another process

when one process is blocked.

2. But the processor is so much faster than I/O

that it will be common for all of the processes

in memory to be waiting for I/O. Thus, even

with multiprogramming, a processor could be

Problem

discover yourself

(4)

The solution is swapping, which involves moving

part or all of a process from main memory to

disk. When none of the processes in main

memory is in the Ready state, the OS swaps one

of the blocked processes out onto disk into a

suspend queue.

The OS then brings in another process from the suspend queue, or it honors a new-process request. Execution then continues with the newly arrived process.

Solution

discover yourself

(5)

Swapping, however, is an I/O operation, and

therefore there is the potential for making the

problem worse, not better.

But because disk I/O is generally the fastest I/O

on a system (e.g., compared to tape or printer

I/O), swapping will usually enhance performance.

discover yourself

(6)

With the use of swapping as just described, one other state must be added to our process behavior model:

THE SUSPEND STATE

When all of the processes in main memory are in the Blocked state, the OS can suspend one process by putting it in the Suspend state and transferring it to disk. The space that is freed in main memory can then be used to bring in another process.

discover yourself

(7)

SUMMARY

1. All processes have space allocated in main memory.

2. Sometimes there will be NO processes in the Ready state, because they are all blocked.

3. So the OS could suspend one of these blocked processes: swap it out to auxiliary memory (disk).

4. And the OS can admit, or activate either a new process, or one that was swapped out earlier.

5. So we will add a Suspend state, for those processes swapped out of memory.

discover yourself

(8)

Process State Transition Diagram with

Suspend State (Swapping

)

discover yourself

(9)

When the OS has performed a swapping-out

operation, it has two choices for selecting a

process to bring into main memory:

1. It can admit a newly created process

2. It can bring in a previously suspended

process.

It would appear that the preference should be to

bring in a previously suspended process, to

provide it with service rather than increasing the

discover yourself

(10)

All of the processes that have been suspended were in the Blocked state at the time of suspension. It clearly would not do any good to bring a blocked process back into main memory, because it is still not ready for execution. However, that each process in the Suspend state was originally blocked on a particular event. When that event occurs, the process is not blocked and is potentially available for execution.

7 States Transition Model

discover yourself

(11)

1. Processor is faster than I/O so all executable

processes could be waiting for I/O, while there

are some new processes waiting to be admitted

2. Swap these processes to disk to free up more

memory to admit new processes

3. Blocked state becomes suspend state when

swapped to disk

4. Two new states

Blocked/Suspend

Suspended Processes

discover yourself

(12)

Functions of Four States

Ready:

the process is in the main memory and available for execution.

Blocked:

the process is in the main memory and awaiting an event to occur.

Blocked/Suspend:

the process is in secondary memory and awaiting an event.

Ready/Suspend:

the process is in the secondary memory but available for execution as soon as it is loaded into the main memory.

Whether a process is waiting for an event (blocked or not)

and whether a process has been swapped out of main memory (suspended or not).

To accommodate this 2 X 2 combination, we need four states:

discover yourself

(13)

But it is better to add two states to keep track of those that are still blocked, and those which are no

discover yourself

inspire posterity

New

Admit Admit Suspend

(14)

Blocked TO Blocked/Suspend:

If there are no ready processes, then at least one blocked process is swapped out to make room for another process that is not blocked.

Blocked/Suspend TO Ready/Suspend:

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

Ready/Suspend TO Ready:

When there are no ready processes in main memory, the OS will need to bring one in to continue execution. In addition, it might be the case that a process in the Ready/Suspend state has higher priority than any of the processes in the Ready state.

discover yourself

(15)

Ready TO Ready/Suspend

It may be necessary to suspend a ready process if that is the only way to free up a sufficiently large block of main memory.

New TO Ready/Suspend and New TO Ready:

When a new process is created, it can either be added to the Ready queue or the Ready/Suspend queue. In either case, the OS must allocate an address space to the process. It can maintain a large pool of processes that are not blocked. With this strategy, there would often be

discover yourself

(16)

Running TO Ready/Suspend:

Normally, a running process is moved to the Ready state when its time allocation expires. If, however, the OS is pre-empting the process because a higher-priority process on the Blocked/Suspend queue has just become unblocked, the OS could move the running process directly to the (Ready/Suspend) queue and free some main memory.

discover yourself

(17)

Running

Blocked Ready

1 2

3 4

5 6

1: process blocks for input

2: scheduler picks another process 3: scheduler picks this process

4: input becomes available 5: process blocks for input

Which state transition is

impossible?

discover yourself

References

Related documents

For this, OpenFPM provides an encapsulated serialization/de-serialization sub-system that is used by each processor locally in order to serialize the local pieces of a distributed

The production of MC-LR by cyanobacteria populations reported in this study and the report of the toxin associated with the presence of Microcystis in 1999 and 2000 (Ramírez et

Abstract The introduction of collaborative planning in integrated water resources management (IWRM) requires new decision support tools (DST) to support the integration of

Açıklık uzunlukları ve mesnetlendiği noktaları belli olan betonarme sürekli kirişin kesit boyutları her açıklık için rassal olarak kullanıcı tarafından belirlenen bir

Microlayer water, mixed layer water, epipellic and benthic sediments were collected from Agboyi Creek, Lagos to analyse organochlorine pesticide residues.. Sampling was

With Introductory pages, containg the First American Charter, the Fir^t American Pronunziamento, a Chart of the Official Symbols and Seals, Record Blanks of

Petroleum Systems and ¨Kitchens¨ in Peruvian hydrocarbon basins SP CHONTA SP PUCARA SP ENE Colombia Ecuador Brasil Cuenca Cuenca Ucayali SP CABANILLAS SP AMBO SP AMBO

Using SWOT method is analyzed external and internal factors of forestry and institutional resources of Sampetan Land and Water Conservation Group.. Keywords :