• No results found

lecture 19 chapter 4

N/A
N/A
Protected

Academic year: 2020

Share "lecture 19 chapter 4"

Copied!
37
0
0

Loading.... (view fulltext now)

Full text

(1)

discover yourself

inspire posterity

CHAPTER 4

(2)

discover yourself

inspire posterity

4.1 Basic Memory Management

4.2 Swapping

4.3 Virtual Memory

4.4 Page Replacement Algorithms

4.5 Modeling Page Replacement Algorithms

4.6 Design Issues for Paging Systems

(3)

discover yourself

inspire posterity

Ideally programmers want memory that is – large

fast

non volatile

Memory Hierarchy

small amount of fast, expensive memory some medium-speed, medium price

gigabytes of slow, cheap storage

(4)

discover yourself

inspire posterity

Jobs of Memory Manager

1- Keep track of which part of the memory in use and which parts are not in use.

2- To allocate memory to processes when they need it and de-allocate it when they are done.

3- Manage swapping between main

(5)

discover yourself

inspire posterity

Memory Management

That move processes back and forth between main memory and disk during execution

That do not move processes back

(6)

discover yourself

inspire posterity

The simplest memory abstraction is no abstraction at all. Early mainframe computers (before 1960), early minicomputers (before 1970), and early personal computers (before 1980) had no memory abstraction. Every program simply saw the physical memory. When a program executed an instruction like MOV REGISTER1 , 1000

the computer just moved the contents of physical memory location 1000 to REGISTER 1 .

Thus the model of memory presented to the programmer was simply physical memory, a set of addresses from 0 to some maximum, each address corresponding to a cell containing some number of bits, commonly eight.

(7)

discover yourself

inspire posterity

Under these conditions, it was not possible to have two running programs in memory at the same time. If the first program wrote a new value to, say, location 2000, this would erase whatever value the second program was storing there. Nothing would work and both programs would crash almost immediately.

(8)

discover yourself

inspire posterity

Three simple ways of organizing memory

Only one process at a time can run.

NO MEMORY ABSTRACTION

The third model was used by early personal computers (e.g., running

(9)

discover yourself

inspire posterity

P1

Processes

OS copies the requested program from disk to memory and executes it

finishes

(10)

discover yourself

inspire posterity

-

Monoprogramming is hardly used except embedded

systems.

-

Modern systems allow multiprogramming.

-

Multiprogramming increases the CPU utilization.

(11)

discover yourself

inspire posterity

Multiprogramming with Fixed Partitions

Fixed memory partitions

separate input queues for each partitionsingle input queue

The easiest way to achieve multiprogramming is to divide memory into unequal

partitions. When a job arrives, it can be put into the input

queue for the smallest partition large enough to hold it.

Whenever a partition becomes free that job in front of the

(12)

discover yourself

inspire posterity

Disadvantages of separate input queues for each partition

1- Any space in the partition not used by the job is wasted.

2-Queue for a large partition is empty but the queue for a small partition is full.

(13)

discover yourself

inspire posterity

P1

P2

P3

P4 Processes

Swapping

Swapping

consists of bringing each process in the

(14)

discover yourself

inspire posterity

(15)

discover yourself

inspire posterity

Difference between fixed and variable partitions

1- The number, location and size of the partitions vary as processes come and go.

2- Allocating and de-allocating memory is complicated.

(16)

discover yourself

inspire posterity

Data Compaction

“When swapping creates multiple holes in memory, it is possible to combine then into one big one by moving all the processes downwards. This technique is called data compaction.”

C B D

Data

(17)

discover yourself

inspire posterity

How much memory should be allocated for a process when it is swapped in?

OS allocates exactly what is needed if process is of

fixed size.

If a hole is adjacent to the process, it can be allocated

(18)

discover yourself

inspire posterity

What if the process is adjacent to another process ?

1- The growing process will have to be moved to another available hole large enough for it.

2- One or more processes will have to be swapped out to create large enough hole.

(19)

discover yourself

inspire posterity

a) Allocating space for growing data segment

b) Allocating space for growing stack & data segment

(20)

Memory Management with Bit Maps

discover yourself

inspire posterity

There are two ways to keep track of memory usage.

1- Bitmaps

(21)

Memory Management with Bit Maps & Link List

10/07/2020 21

discover yourself

inspire posterity

Part of memory with 5 processes, 3 holestick marks show allocation unitsshaded regions are free

(22)

Memory Management with Linked Lists

discover yourself

inspire posterity

(23)

Dynamic Partitioning

Placement Algorithm

Operating system must decide which free

block to allocate to a process

discover yourself

(24)

Placement ALGORITHMS used to allocate memory for newly created process OR existing process swapped in from the disk.

1- First Fit (FF) 2- Next Fit (NF) 3- Best Fit (BF) 4- Worst Fit (WF)

discover yourself

(25)

ALGORITHMS

NOTE: Assume that the memory manager knows how much memory to allocate.

1- First Fit (FF)

“Scans memory form the beginning and chooses the first available block that is large enough.”

The memory manager scans along the list of segments until it finds a hole that is

big enough. The hole is then broken up into two pieces, one for the process and one for unused memory.

Next time it is called to find a hole, it starts searching the list from the beginning.

discover yourself

(26)

Example:

If a block of size 2 is needed, FF will allocate a hole at_______.

discover yourself

(27)

Bin Packing First Fit Algorithm

1 2 3 6 2 3 5 3 4

Each block will be fitted into the first bin that has room for it.

Each block will be fitted into the first bin that has room for it.

A B C D E F

Scan all bins and place item in first bin large enough to hold it

discover yourself

(28)

4

The first block fits into the first bin

The first block fits into the first bin

6

A B C D E F

discover yourself

(29)

4

The second block fits in the first bin

The second block fits in the first bin

1

2 3

6

2 3

5

3

A B C D E F

discover yourself

(30)

4 1

6 2

2

But there is room in the second bin

But there is room in the second bin

A B C D E F

discover yourself

(31)

The third bin is the first one the 5 will fit in

The third bin is the first one the 5 will fit in

4 1 2 6 3 5 3 2 3 5 5

A B C D E F

discover yourself

(32)

The second bin has room for the 3

The second bin has room for the 3

4 1

6 2

3

5 3

A B C D E F

discover yourself

(33)

The fourth bin is the first one with room for the next one

The fourth bin is the first one with room for the next one

4 1 2 6 3 3 2 3 5 2 2 2

A B C D E F

discover yourself

(34)

The next one also fits in the fourth bin

The next one also fits in the fourth bin

4 1

6 2

3

5

2

3 3 3

3

A B C D E F

discover yourself

(35)

No room until the fifth bin for the 6

No room until the fifth bin for the 6

4 1 6 3 2 3 5 2 3

6 6 6

6

A B C D E F

discover yourself

(36)

The 3 has to start a new bin

4 1

2 3

5

2 3

6

3 3 3 3

3

3

A B C D E F

discover yourself

(37)

discover yourself

References

Related documents

The City of Surrey’s Planning and Development Department in partnership with the Information Technology Division has recently implemented an information system for the storage

As the utilities lost their credit capacity, in January 2001 the state’s government began to buy energy directly from the generators, in order to supply the regulated consumers..

Nevertheless, most of the studies of the waqf as mentioned earlier do not support their findings with statistical and empirical evidence of the performance of the

The Committee presents its views to the SEC as follows: (1) client- retention incentives that could impair independence exist in the absence of nonaudit services, so the

door (entry or cargo) open main gear steering unlocked pk brake set flaps Vs FMS rudder trim > 2 degrees spoilers not forward stab outside green band 1 or 2 warning lights inop 1

Gerade beim E-Book Dienst, aber auch beim neuen Workflow für Visual Library hat sich ge- zeigt, dass die Alma Architektur hinsichtlich der „Replikation“ konträr zu Aleph ist und

In our survey, we have shown that the rate of creditor satisfaction drops with the amount of aggregate debtor receivables, while close to a third of debtors in the scope of