Answers: Chapter 5: Memory Management Exercises
Answers: Chapter 5: Memory Management Exercises
ANSWERS
Exercises:
The shaded areas are allocated blocks; the white areas are free blocks.
Using the following placement algorithms, show the partition allocated for the processes of size
110K, 150K, 300K and 200K (loaded in that order):
a) First-fit
b) Best-fit
c) Next-fit
First fit:
150K
110K
300K 200K
50 250K
100K
K
200K 500K 300K 100K
Best fit:
110K
150K
300K 200K
50
100K 250K
K
200K 500K 300K 100K
Next fit:
Last allocated block
300K 200K
K
110
K
150
100K 50
250K
K
200K 500K 300K 100K
2. Consider the following segment table
What are the physical addresses for the following logical addresses or indicate if a segment fault
occurs
3. Dynamic partitioning scheme is being used, and the following is the main memory
configuration is given:
Last allocated block
50K
100
100
The shaded areas are allocated blocks; the white areas are free blocks.
Using the following placement algorithms, show the partition allocated for the processes of size
119K, 455K, 212K and 145K (loaded in that order):
a) First-fit
455K
119K
212K
145K
50K
100
250K
K
200K
100K 500K 300K 600K
b) Best-fit
200K 455K
145K
212K
119K
50K
100
250K
K
455K
145K
212K
119K
50K
100
200K 250K
K
16 X.0
New process list
17 X.1
Page Z.0 18 Y.0
Page Z.1 19 Z.0
Page Z.2 20 Z.1
a) Show the frame (in the physical memory) that is allocated to each page of the new
process.
X Y Z
0 16 0 18 0 19
1 17 1 21 1 20
2 23 2 22
3 24
0 000101
1 000111
2 001001
3 001011
4 001100
Process Page Table
Determine the physical address of the following logical address for this scheme.
a) 0001000001111110
b) 0000111111111111
Answers:
a) 0001000001111110 = 0011000001111110
Page 4 Offset Frame
b) 0000111111111111 = 0010111111111111
Page 3 Offset Frame
7. Consider a simple segment system which uses 16 bits addressing scheme. The segment size is
1K each. Given a process segment table as follows,
Determine the physical address of the following logical address for this scheme.
a) 0000010111100000
b) 0001001110001111
Answers:
a) 0000010111100000
Offset
Segment 0 Base: 0000000010100000 +
Offset: 010111100000
0000011010000000
b) 0001001110001111
240M
Rq
30M A=30M 30M 60M 120M
Rq
50M
A=30M 30M B=50M 120M
Rq
60M A=30M 30M B=50M C=60M 60M
Return
A
60M B=50M C=60M 60M
Rq
40M D=40M B=50M C=60M 60M
Return
B
D=40M 60M C=60M 60M
Return
C D=40M 60M 120M
Return
D
240M
9. Describe a mechanism for enforcing memory protection in order to prevent a program from
modifying the memory associated with other programs.
The processor could keep track of what locations are associated with
each process and limit access to locations that are outside of a
program’s extent. Information regarding the extent of a program’s
memory could be maintained by using base and limit registers and by
performing a check for every memory access.
11. Why does fix partitioning suffer from internal fragmentation whereas dynamic partitioning
suffers from external fragmentation? When is compaction needed?
12. What is the difference between a physical address and a logical address?
13. What is the difference between page, frame and segment in memory management?
14. In memory management, block of data loaded into memory partitioning can cause a condition
called fragmentation. Define fragmentation and explain briefly types of fragmentation that
exists.