MemoryManagement Exercises
MemoryManagement Exercises
Course recap
Exercise 1
Consider a machine with a main memory of 32 KB. The resident part of the operating system occupies
the first 10 KB. The following requests are given:
We assume that the system uses contiguous allocation based on fixed partitions, and a process loaded
into central memory will remain there until the end of its execution. The system employs Best Fit as
the placement strategy and uses FCFS for process scheduling.
give the main memory occupation at different stages of processing and the corresponding Gantt
chart for their scheduling in each of the following cases:
Exercise 2
Given a memory of 2 Megabytes (2048 KB), with 300 KB reserved for the operating system. In a
multiprogramming context, we propose to divide the memory space reserved for user programs into
5 fixed-size partitions as follows: 100 KB, 500 KB, 200 KB, 300 KB, and 600 KB (in this order).
1. Knowing that the process queue contains the following list: P1 (212 KB), P2 (417 KB), P3
(112 KB), P4 (426 KB) (in this order), provide the scenario of memory occupation for each
1/4
Operating System
of the algorithms First-fit, Best-fit, and Worst-fit. In other words, how would the system place
these processes?
2. Which algorithm achieves the most efficient use of memory in this case? Conclusion.
Exercise 3
Consider a computer system that uses fixed partition memory management with two partitions of
sizes 200 KB and 300 KB. The system has a total memory size of 512 KB. The 12 remaining are
use to the resident operating System ( We suppose that this partition is located at the end of memory
space).
1. Memory Allocation:
o Process A requests 150 KB of memory.
o Process B requests 250 KB of memory.
o Process C requests 100 KB of memory.
2. Memory Deallocation:
o Process A completes its execution and releases its allocated memory.
o Process D requests 180 KB of memory.
o Process B completes its execution and releases its allocated memory.
Update the memory allocation for the new requests and deallocations.
Exercise 4
Consider a system using memory allocation based on variable partitions. The placement in central
memory follows the First Fit strategy. We assume that the size of the User partition in central memory
is 175 KB. At a given moment t, the state of central memory is as follows:
A B C D E F
10KB 10KB 20KB 30KB 10KB 5KB 30KB 10KB 5KB 15KB 20KB 10KB
2/4
Operating System
Knowing that:
Represent the central memory evolution after the arrival of the following events in the order specified
below:
b. Departure of program B.
d. Departure of program E.
Exercise 5
Consider a system using contiguous allocation based on variable partitions. The size of the central
memory is 1000 blocks. The following allocation and deallocation requests are given: (-250), (-200),
(-100), (-150), (+250), (-300), (+100), (+300), (-50), (-100), (-200), and (-100). We assume that the
'-' sign indicates allocation, while the '+' sign denotes deallocation. It is assumed that the central
memory is initially free. How will the system process these allocation/deallocation requests for the
first-fit, best-fit, and worst-fit relocation strategies?"
Exercise 6
Consider an operating system that uses paging for memory space allocation.
1. Given that the memory address size is 32 bits, what is the maximum size that memory can
reach in this case, knowing that 1 Word = 1 Byte?
2. Assuming we use pages of 256 Bytes, what is the number of bits reserved in an address to
designate the offset within the page?
3. Assuming that in a program, we reference the next virtual address: Page number = 3 (in base
10) and offset within the page = 10 (in base 10). Given that page 3 is loaded into frame 5,
determine the corresponding real address (physical address) for this virtual address in binary."
3/4
Operating System
Exercise 7
Consider a process composed of 5 pages. Knowing that a virtual address is encoded with 32 bits: 16
bits for the page number and 16 bits for the offset within the page. At the time of loading the process,
there are 5 available frames, which are (0A)hex, (1Ah)hex, (1D)hex, (20)hex, (21)hex. The preceding
values represent the numbers of the free frames at the time of loading in hexadecimal.
Question: What is the corresponding real (effective) address for the virtual address (000200FE)hex,
considering that the page (0002)hex is loaded into the frame (001D)hex?"
Exercise 8
1. Consider a system that uses 32-bit memory addresses. determine the maximum size of the
memory that can be used?
2. Knowing that the leftmost 22 bits of a virtual address indicate the page number in the program,
and the rightmost 10 bits denote the offset from the beginning of the page. Determine the size
of the page?
3. Given the state of occupation of the following physical memory, transform the following
virtual addresses into real addresses: 0000000000000000000000101 1010111010,
000000000000000000011 1011110001
…
1
7
3 Page number 3 is loaded in frame 1
5 Page number 5 is loaded in frame 0
Physical Memory occupation
Exercise 9
Consider an operating system that uses the virtual memory solution based on Paging. This system
provides its users with an addressable space of 4 GB (232).
1. What is the size of a memory address in this case? (We are looking for the size of the virtual
address.)
2. Knowing that 8 bits of this address are used for the page number, what is the size of the
memory page in this case?
• The physical memory of this system has a size of 1 GB (230). Determine the following
virtual address: Page number = 3 (in base 10) and offset within the page = 10 (in base
10). Knowing that page 3 is loaded into frame 5, determine the corresponding real
address (physical address) for this virtual address in binary.
4/4