Main Memory
Main Memory
Main Memory
Memory Management
0
1
2
3
4
.
.
n
2
Memory Management
To improve both the utilization of the CPU and the speed of the
computer’s response to its users, general-purpose computers must
keep several programs in memory, creating a need for memory
management.
3
Cont.
4
8.1.1 Basic Hardware
OS area
User area
5
8.1.1 Basic Hardware
6
Cont.
7
Figure 8.1 A base and a limit register define a
logical address space.
The base register holds the smallest
legal physical memory address.
The limit register specifies the size
of the range.
For example, if the base register holds
30004 and the limit register is 12090,
then the program can legally access all
addresses from 30004 through 42094 .
8
8.1.3 Logical Versus Physical Address Space
9
8.1.3 Logical Versus Physical Address Space
10
Figure 8.4 Dynamic relocation using a relocation
register.
Reallocation memory
register
14000
logical Physical
address address
CPU +
346 14346
11
Cont.
12
8.1.4 Dynamic Loading
13
Advantages
14
8.2 Swapping
15
8.2 Swapping
16
Figure 8.5 Swapping of two processes using a
disk as a backing store.
17
8.2.2 Swapping on Mobile Systems
Although most operating systems for PCs and servers support some modified
version of swapping, mobile systems typically do not support swapping in any
form.
Mobile devices generally use flash memory rather than more spacious hard disks
as their persistent storage. The resulting space constraint is one reason why
mobile operating-system designers avoid swapping.
Other reasons include the poor throughput between main memory and flash
memory in these devices.
18
8.3 Contiguous Memory Allocation
19
Cont.
20
8.3.2 Memory Allocation
21
Fixed-partition scheme
22
Variable-partition scheme
As processes enter the system, they are put into an input queue. The operating
system takes into account the memory requirements of each process and the
amount of available memory space in determining which processes are
allocated memory.
When a process is allocated space, it is loaded into memory, and it can then
compete for CPU time.
When a process terminates, it releases its memory, which the operating system
may then fill with another process from the input queue.
23
Cont.
24
Cont.
25
Best - Fit
Best - Fit - chooses a partition that is smallest and whose size is greater than or
equal to k. It leaves small-sized unusable partitions or holes.
26
First - fit
First - fit - chooses the first partition whose size is greater than or equal to k.
27
Worst - fit
Worst - fit - chooses the largest partition and allocates it to process p. It can
leave bigger unusable partitions.
28
29
30