计算机代考 COMP30023 – Computer Systems

COMP30023 – Computer Systems

© University of Melbourne 2022

Copyright By PowCoder代写 加微信 powcoder

Operating systems:
Memory Management

• Announcement on LMS
• Spec is available via LMS
• Extra consultation hours

© University of Melbourne 2

Project 1 is out

© University of Melbourne 3

Recap: Process

Process: program in execution
Process memory has three segments:

– text (program code, usually “read only”)
– data (constant data strings, global vars)
– stack (local vars)

• Memory hierarchy
• Basic memory management
• Memory allocation

© University of Melbourne

Requirements:
• Non-volatile

• Different types of memory with different properties
• Higher speed, smaller capacity, greater cost

© University of Melbourne 5

Memory specifications

© University of Melbourne 6

Memory hierarchy

Figure 1-9. A typical memory hierarchy. The numbers are very rough
approximations.

© University of Melbourne 7

• Controlled by hardware
• Split in cache lines (typically, 64 byte each)
• Cache Hit : Desired data is in current level of cache
• Cache Miss : Desired data is not present in current level

1. When to put a new item into the cache.
2. Which cache line to put the new item in.
3. Which item to remove from the cache when a slot is needed.
4. Where to put a newly evicted item in the larger memory.

© University of Melbourne 8

Cache Decisions

• RAM (Random Access Memory)
• Volatile
• Megabytes to gigabytes in size

© University of Melbourne 9

Memory or RAM

+ Cheaper than RAM per bit
+ Often 2x magnitude larger
– Slow random memory access

© University of Melbourne 10

© University of Melbourne 11

Memory hierarchy

Figure 1-9. A typical memory hierarchy. The numbers are very rough
approximations.

© University of Melbourne 12

Memory requirement of D

Why memory management (1)

• The sizes of main memories have been increasing dramatically,
roughly quadrupling every three years.

• However, the demands for main memory have been increasing
almost as fast.

© University of Melbourne 13

Why memory management (2)

• to allocate memory to processes when they require it
• to deallocate when finished
• to protect memory against unauthorized accesses, and
• to simulate the appearance of a bigger main memory by moving

data automatically between main memory and disk
• to keep track of which parts of memory are free and which parts

are allocated (and to which process)

Memory manager functionality

© University of Melbourne

• Absolute memory
• Relocate
• Expose physical memory to processes
• Consequences: security and multiple processes
• Q: How to ensure mutually exclusive access?

© University of Melbourne 15

What if no memory abstraction

© University of Melbourne 17

No memory abstraction:
multiple processes

Figure 3-2. Illustration of the relocation problem. (a) A 16-KB program. (b) Another 16-KB
program. (c) The two programs loaded consecutively into memory.

© University of Melbourne 18

No memory abstraction:
multiple processes

Figure 3-2. Illustration of the relocation problem. (a) A 16-KB program. (b) Another 16-KB
program. (c) The two programs loaded consecutively into memory.

© University of Melbourne 19

No memory abstraction:
multiple processes

Base register

Figure 3-2. Illustration of the relocation problem. (a) A 16-KB program. (b) Another 16-KB
program. (c) The two programs loaded consecutively into memory.

© University of Melbourne 20

No memory abstraction:
multiple processes

Figure 3-2. Illustration of the relocation problem. (a) A 16-KB program. (b) Another 16-KB
program. (c) The two programs loaded consecutively into memory.

Base register

Limit register

Base and limit registers can
be used to give each
process a separate address

© University of Melbourne 25

Base and Limit Registers

• to allocate memory to processes when they require it
• to deallocate when finished
• to protect memory against unauthorized accesses, and
• to simulate the appearance of a bigger main memory by moving

data automatically between main memory and disk
• to keep track of which parts of memory are free and which parts

are allocated (and to which process)

Memory manager functionality

© University of Melbourne

• to allocate memory to processes when they require it
• to deallocate when finished
• to protect memory against unauthorized accesses, and
• to simulate the appearance of a bigger main memory by moving

data automatically between main memory and disk
• to keep track of which parts of memory are free and which parts

are allocated (and to which process)

Memory manager functionality

© University of Melbourne

Memory allocation changes as processes come into memory and
leave it. The shaded regions are unused memory

© University of Melbourne 28

• to allocate memory to processes when they require it
• to deallocate when finished
• to protect memory against unauthorized accesses, and
• to simulate the appearance of a bigger main memory by moving

data automatically between main memory and disk
• to keep track of which parts of memory are free and which parts

are allocated (and to which process)

Memory manager functionality

© University of Melbourne

(a) A part of memory with five processes and three holes. The tickmarks
show the memory allocation units. The shaded regions (0 in the
bitmap) are free

(b) The corresponding bitmap

© University of Melbourne 30

Memory Management with Bitmaps

© University of Melbourne 31

Memory Management with Bitmaps

(a) A part of memory with five processes and three holes. The tickmarks
show the memory allocation units. The shaded regions (0 in the
bitmap) are free

(c) The same information as a list.

Four neighbor combinations for the terminating process, X.

© University of Melbourne 32

Memory Management with Linked

• to allocate memory to processes when they require it
• to deallocate when finished
• to protect memory against unauthorized accesses, and
• to simulate the appearance of a bigger main memory by moving

data automatically between main memory and disk
• to keep track of which parts of memory are free and which parts

are allocated (and to which process)

Memory manager functionality

© University of Melbourne

• First fit
• Next fit
• Best fit
• Worst fit
• Quick fit

© University of Melbourne 34

Memory Management Algorithms

Managing free memory:
How to choose the next free

• to allocate memory to processes when they require it
• to deallocate when finished
• to protect memory against unauthorized accesses, and
• to simulate the appearance of a bigger main memory by moving

data automatically between main memory and disk
• to keep track of which parts of memory are free and which parts

are allocated (and to which process)

Memory manager functionality

© University of Melbourne

fragmentation

© University of Melbourne 36

Swapping & Fragmentation

• Memory hierarchy
• Memory allocation

© University of Melbourne 37

• Announcement on LMS
• Spec is available via LMS
• Extra consultation hours

© University of Melbourne 38

Project 1 is out

• The slides were prepared by .
• Some material is borrowed from slides developed by

, , , , , and .

• Some of the images included in the notes were supplied as
part of the teaching resources accompanying the text books
listed in lecture 1.

• Reference: TB 1.3.2, 3, 3.1, 3.2

Acknowledgement

© University of Melbourne

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com