MEMORY MANAGEMENT-1
MEMORY MANAGEMENT-1
Q 1 Explain fixed partition. (2012)
The first
attempt to allow for multiprogramming used fixed partitions (also called
static partitions) within the main memory—one partition for each job.
Because the size of each partition was designated when the system was powered
on, each partition could only be reconfigured when the computer system was shut
down, reconfigured and restarted. Thus,
once the system was in operation the partition sizes remained static.
The fixed
partition scheme works well if all of the jobs run on the system are of the same
size or if the sizes are known ahead of time and don’t vary between
reconfigurations. Ideally, that would require accurate advance knowledge of all
the jobs to be run on the system in the coming hours, days, or weeks.
Partial usage
of fixed partitions and coinciding creation of unused spaces within partitions
is called internal fragmentation and is a major drawback to the fixed partition
memory allocation scheme.
Q 2 Explain Dynamic partition. (2012)
With dynamic
partitions, available memory is still kept in contiguous blocks but jobs are
given only as much memory as they request when they are loaded for processing. Although
this is a significant improvement over fixed partitions because memory isn’t wasted
within the partition, it doesn’t entirely eliminate the problem. As shown in
Figure a dynamic partition scheme fully
utilizes memory when the first jobs are loaded. But as new jobs enter the
system that are not the same size as those that just vacated memory, they are
fit into the available spaces on a priority basis.
Demonstrates first-come,
first-served priority. Therefore, the subsequent allocation of memory
creates fragments of free memory between blocks of allocated memory. This problem
is called external fragmentation and, like internal fragmentation, lets
memory go to waste.
Q.3 what is first-fit and best-fit allocation.(2012)
First-fit allocation
This method keeps the free/busy lists
organized by memory locations, low-order memory to high order memory. It is a
faster in making the allocation. It is a fast in allocation but it is not
always efficient.
Example:
Job list
Job number |
Memory requested |
J1 |
10k |
J2 |
20k |
J3 |
30k |
J4 |
10k |
Memory location |
Memory block size |
Job number |
Job size |
Status |
Internal fragmentation |
10240 |
30k |
J1 |
10k |
Busy |
20k |
40960 |
15k |
J4 |
10k |
Busy |
5k |
56320 |
50k |
J2 |
20k |
Busy |
30k |
107520 |
20k |
|
|
Free |
|
Best-fit allocation
This method
keeps the free/busy lists in order by size, smallest to largest. It usually
makes the best use of memory space. Disadvantages of this system are that it is
wasting time looking for the best space.
Example:
Job list
Job number |
Memory requested |
J1 |
10k |
J2 |
20k |
J3 |
30k |
J4 |
10k |
Memory list
Memory location |
Memory block size |
Job number |
Job size |
Status |
Internal fragmentation |
40960 |
15k |
J1 |
10k |
Busy |
5k |
107520 |
20k |
J2 |
20k |
Busy |
None |
10240 |
30k |
J3 |
30k |
Busy |
None |
56320 |
50k |
J4 |
10k |
Busy |
40k |
Q 4 Explain Deallocation. (2012)
For a fixed
partition system, the process is quite straightforward. When the job is
completed, the Memory Manager resets the status of the memory block where the
job was stored to “free.” Any code—for example, binary values with 0 indicating
free and 1indicating busy—may be used so the mechanical task of deallocating a
block of memory is relatively simple.
A dynamic
partition system uses a more complex algorithm because the algorithm tries to
combine free areas of memory whenever possible. Therefore, the system must be prepared
for three alternative situations:
Case 1. When
the block to be deallocated is adjacent to another free block
Case 2. When
the block to be deallocated is between two free blocks
Case 3. When
the block to be deallocated is isolated from other free blocks
Case 1: Joining
Two Free Blocks
Table shows how
deallocation occurs in a dynamic memory allocation system when the job to be
deallocated is next to one free memory block.
Beginning Address Memory Block Size Status
4075 105
Free
5225
5
Free
6785
600 Free
7560
20
Free
(7600)
(200) (Busy)1
*7800
5
Free
10250
4050
Free
15125
230
Free
24500 1000 Free
1Although the
numbers in parentheses don’t appear in the freelist, they’ve been inserted here
for clarity. The job size is 200and its beginning location is 7600.After
deallocation the free list looks like the one shown in Table
Beginning Address Memory Block Size Status
4075
105 Free
5225
5 Free
6785
600 Free
7560
20 Free
*7600
205 Free
10250
4050 Free
15125
230 Free
24500 1000
Free
Case 2: Joining
Three Free Blocks
When the
deallocated memory space is between two free memory blocks, the processis
similar, as shown in Table. Using the deallocation algorithm, the system learns
that the memory to be deallocatedis between two free blocks of memory.
Therefore, the sizes of the three free partitions(20 + 20 + 205) must be
combined and the total stored with the smallest beginningaddress, 7560.
Beginning Address Memory Block Size Status
4075 105 Free
5225
5 Free
6785
600 Free
*7560
20 Free
(7580)
(20) (Busy)1
*7600
205 Free
10250
4050 Free
15125
230 Free
24500 1000
Free
Because the
entry at location 7600 has been combined with the previous entry, wemust empty
out this entry. We do that by changing the status to null entry, with
nobeginning address and no memory block size as indicated by an asterisk in
Table. This negates the need to rearrange the list at the expense of memory.
Beginning Address Memory Block Size Status
4075
105 Free
5225
5 Free
6785
600 Free
7560
245 Free
*
(null entry)
10250 4050
Free
Case 3:
Deallocating an Isolated Block
The third
alternative is when the space to be deallocated is isolated from all other free
areas. For this example, we need to know more about how the busy memory list is
configured.To simplify matters, let’s look at the busy list for the memory area
between locations7560 and 10250. Remember that, starting at 7560, there’s a
free memory blockof 245, so the busy memory area includes everything from
location 7805 (7560 + 245)to 10250, which is the address of the next free
block. The free list and busy list are shown in Table 2.8 and Table 2.9.
Beginning Address Memory Block Size Status
4075
105 Free
5225
5 Free
6785
600 Free
7560 245
Free
(null entry)
10250 4050
Free
15125
230 Free
24500 1000
Free
Beginning
Address Memory Block Size Status
7805 1000 Busy
*8805 445 Busy
9250 1000 Busy
Using the deallocation
algorithm, the system learns that the memory block to be released is not
adjacent to any free blocks of memory; instead it is between two other busy
areas. Therefore, the system must search the table for a null entry. The scheme
presented in this example creates null entries in both the busy and the free lists
during the process of allocation or deallocation of memory.
Beginning
Address Memory Block Size Status
7805 1000
Busy
* (null entry)
9250 1000 Busy
When
the null entry is found, the beginning memory location of the terminating job
is entered in the beginning address column, the job size is entered under the
memory block size column, and the status is changed from a null entry to free
to indicate that a new block of memory is available, as shown in Table
Beginning Address Memory Block Size Status
4075
105 Free
5225
5 Free
6785
600 Free
7560
245 Free
*8805
445 Free
10250
4050 Free
15125
230 Free
24500 1000 Free
Q 5 Explain Relocatable
Dynamic Partitions
Both of the
fixed and dynamic memory allocation schemes described thus far shared some
unacceptable fragmentation characteristics that had to be resolved by relocatable
dynamic partitions.With this memory allocation scheme, the Memory Manager
relocates programs togather all of the empty blocks and compact them to make
one block of memory large enough to accommodate some or all of the jobs waiting
to get in.The compaction of memory, sometimes referred to as garbage
collection or defragmentation, is performed by the operating system to reclaim
fragmented sections of the memory space Compaction isn’t an easy task. First,
every program in memory must be relocated sothey’re contiguous, and then every
address, and every reference to an address, within each program must be
adjusted to account for the program’s new location in memory.However, all other
values within the program (such as data values) must be left alone. In other
words, the operating system must distinguish between addresses and data
values,and the distinctions are not obvious once the program has been loaded
into memory.