0% found this document useful (0 votes)
2K views6 pages

Answers: Chapter 5: Memory Management Exercises

This document contains sample exam questions about memory management concepts including placement algorithms, segmentation, paging, and buddy system partitioning. It provides examples of using first-fit, best-fit, and next-fit algorithms to allocate memory blocks of different sizes. It also shows examples of address translation using segmentation and paging tables, drawing the appropriate tables and finding physical addresses from logical addresses. Finally, it demonstrates allocating memory using the buddy system partitioning scheme.

Uploaded by

atikur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views6 pages

Answers: Chapter 5: Memory Management Exercises

This document contains sample exam questions about memory management concepts including placement algorithms, segmentation, paging, and buddy system partitioning. It provides examples of using first-fit, best-fit, and next-fit algorithms to allocate memory blocks of different sizes. It also shows examples of address translation using segmentation and paging tables, drawing the appropriate tables and finding physical addresses from logical addresses. Finally, it demonstrates allocating memory using the buddy system partitioning scheme.

Uploaded by

atikur
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Chapter 5: Memory Management

ANSWERS
Exercises:

1. Given memory partitions below:


Last allocated block

200K 100K 500K 50 300K 250K 100


K K

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

Segment Base Length


0 660 248
1 1752 422
2 222 198
3 996 604

What are the physical addresses for the following logical addresses or indicate if a segment fault
occurs

i)0, 198  in Segment 0 => 660 + 198 = 858


ii) 1, 530  in Segment 1 => Illegal reference
ii) 2, 156  in Segment 2 => 222 + 156 = 378
iii) 3, 444  in Segment 3 => 996 + 444 = 1440
iv) 0, 222  in Segment 0 => 660 + 222 = 882

3. Dynamic partitioning scheme is being used, and the following is the main memory
configuration is given:
Last allocated block
50K

100

100

200K 500K 300K 250K 600K


K

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

100K 500K 300K 600K

c) Next-fit Last allocated block

455K
145K
212K
119K
50K

100

200K 250K
K

100K 500K 300K 600K


4. Solve the paging problem based on the information given below: pages of processes X and Y
have already occupied several frames in main memory, while a new process Z is to be loaded in.
Physical
memory

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

Page Z.3 21 Y.1


22 Z.2
23 Y.2
24 Z.3

a) Show the frame (in the physical memory) that is allocated to each page of the new
process.

b) Draw the appropriate page-table for each process.

X Y Z
0 16 0 18 0 19
1 17 1 21 1 20
2 23 2 22
3 24

5. Consider the following segment table:

Segment Base Length


0 996 248
1 2180 422
2 222 198
3 660 204
4 1752 96

a) Illustrate using diagram the places of all segments in main memory.


b) What are the physical addresses for the following logical addresses?

i) 0, 178  in Segment 0 => 996 + 178 = 1174


ii) 1, 256  in Segment 1 => 2180 + 256 = 2436
iii) 2, 130  in Segment 2 => 222 + 130 = 352
iv) 3, 244  in Segment 3 => Illegal reference
v) 4, 73  in Segment 4 => 1752 + 73 = 1825
6. Consider a simple paging system which uses 16 bits addressing scheme. The page size is 1K each.
Given a process page table as follows,

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,

Segment Length Base


0 11110 11111 0000000010100000
1 11100 11111 0000000001111000
2 11111 00000 0000000010011010
3 10000 00000 0000000010010000
4 11111 11111 0000000010101000

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

Segment 1  Base: 0000000001111000 +


Offset: 001110001111
0000010000000111
8. If a memory size is 240MB. By using buddy partitioning scheme, shade the memory insertion
for the memory space request as follows: 30MB, 50MB, 60MB, Return A, Request 40MB,
Return B, Return C and Return D.
Saiz satu ingatan adalah 240MB. Dengan menggunakan skema ‘buddy partitioning’, tunjukkan
lakaran kemasukan ruangan ingatan bagi permintaan ruangan ingatan seperti berikut: 30MB,
50MB, 60MB, Pulangan A, permintaan 40MB, pemulangan B, pemulangan C dan pemulangan
D.

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.

10. What is a main difference between a page and a frame?

In an equal fixed-size memory partitioning, each process is also


divided into small fixed-size chunks of the same size known as pages,
could be assigned to available chunks of memory, know as frames or
page frames.

11. Why does fix partitioning suffer from internal fragmentation whereas dynamic partitioning
suffers from external fragmentation? When is compaction needed?

Fixed partitioning suffers from internal fragmentation because some


processes may use less memory than the fixed partition size.

Dynamic partitioning suffers from external fragmentation because the


memory holes left between two partitions may be too small for another
process to use.

Compaction is used in a system with dynamic partitioning to place all


of the partitions in a contiguous range of memory. The effect of this
is to combine all the small holes into one larger hole.

12. What is the difference between a physical address and a logical address?

A physical address is an actual location in main memory whereas a


logical address is a reference to a memory location independent of the
current assignment of data to memory.

13. What is the difference between page, frame and segment in memory management?

Page - divide each process into the same size chunks


Frames - partition memory into small equal fixed-size chunks
Segment - divide process into segments but do not have to be of the
same length

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.

Fragmentation is a condition that occurs when processes are loaded into


memory and free memory space is broken into pieces.

External fragmentation is a phenomenon associated with dynamic


partitioning, and refers to the fact that a large number of small areas
of main memory external to any partition accumulates.

Internal fragmentation refers to the wasted space internal to a


partition due to the fact that the block of data loaded is smaller than
the partition (fixed partition-page/frame).

You might also like