You are on page 1of 5

Partition Allocation Methods in Memory

Management
In the operating system, the following are four common memory management
techniques.
Single contiguous allocation: Simplest allocation method used by MS-DOS. All
memory (except some reserved for OS) is available to a process.

·         Multiple partition Method:

 Fixed Size partitions:

 Each Partition has exactly one process.

 Degree of multi-programming – bound to - No. of partitions

  When a partition is free, a process is selected from the input queue and is
loaded into free partition.

 When the process terminates, the partition becomes available for another
process.

This restricts both the number of simultaneous processes and the maximum size of
each process, and is no longer used.

Variable Size Partitions

·         Keeps a table of unused (free) memory blocks (holes), and to find a hole of a
suitable size whenever a process needs to be loaded into memory.

·         Initially – all memory is available – large block of available memory – hole.

·         Later – memory contains a set of holes of variable sizes.


·         CPU scheduling algo. – Input queue – allocate when free required size hole is
available – if not wait.

·         Large hole can be splitted into 2 parts – allocate one and add other to hole
set.

·         Merge 2 holes when new hole is adjacent to old hole.

·          There are many different strategies for finding the "best" allocation of memory
to processes, including the three most commonly discussed:

1.      First fit - Search the list of holes until one is found that is big enough to satisfy
the request, and assign a portion of that hole to that process. Whatever fraction of
the hole not needed by the request is left on the free list as a smaller hole.
Subsequent requests may start looking either from the beginning of the list or from
the point at which this search ended.

2.      Best fit - Allocate the smallest hole that is big enough to satisfy the request.
This saves large holes for other process requests that may need them later, but the
resulting unused portions of holes may be too small to be of any use, and will
therefore be wasted. Keeping the free list sorted can speed up the process of finding
the right hole.

3.      Worst fit - Allocate the largest hole available, thereby increasing the likelihood
that the remaining portion will be usable for satisfying future requests.

·         Simulations show that either first or best fit are better than worst fit in terms of
both time and storage utilization. First and best fits are about equal in terms of
storage utilization, but first fit is faster.

8.3.3. Fragmentation

 External Fragmentation exists when there is enough total memory space to


satisfy a request but the available spaces are not contiguous.

 Worst case – block of free memory between every 2 processes and if these
small pieces are one block instead then we might be able to run several more
processes.

 Both best-fit and first-fit suffer with external fragmentation.

 50-percent Rule:

 Statistical analysis of first-fit says for any kind of optimization out of


given N allocated blocks another 0.5N blocks will be lost for
fragmentation.

 Internal fragmentation – unused memory that is internal to a partition.


 When memory is partitioned into fixed-size blocks and allocate memory
in units based on block size then memory allocated to a process may
be slightly larger than the requested memory.

 COMPACTION - Solution for External Fragmentation

 Shuffle the memory contents so as to place all free memory


together in one large block.

 Possible only when binding is during execution time (dynamic)

Logical and Physical Address in Operating System


Logical Address is generated by CPU while a program is running. The logical
address is virtual address as it does not exist physically, therefore, it is also known
as Virtual Address. This address is used as a reference to access the physical
memory location by CPU. The term Logical Address Space is used for the set of all
logical addresses generated by a program’s perspective.
The hardware device called Memory-Management Unit is used for mapping logical
address to its corresponding physical address.
Physical Address identifies a physical location of required data in a memory. The
user never directly deals with the physical address but can access by its
corresponding logical address. The user program generates the logical address and
thinks that the program is running in this logical address but the program needs
physical memory for its execution, therefore, the logical address must be mapped to
the physical address by MMU before they are used. The term Physical Address
Space is used for all physical addresses corresponding to the logical addresses in a
Logical address space.
Mapping virtual-address to physical-addresses
Differences Between Logical and Physical Address in Operating System
1. The basic difference between Logical and physical address is that Logical
address is generated by CPU in perspective of a program whereas the physical
address is a location that exists in the memory unit.
2. Logical Address Space is the set of all logical addresses generated by CPU
for a program whereas the set of all physical address mapped to corresponding
logical addresses is called Physical Address Space.
3. The logical address does not exist physically in the memory whereas physical
address is a location in the memory that can be accessed physically.
4. Identical logical addresses are generated by Compile-time and Load time
address binding methods whereas they differs from each other in run-time
address binding method. Please refer this for details.
5. The logical address is generated by the CPU while the program is running
whereas the physical address is computed by the Memory Management Unit
(MMU).
Comparison Chart:
PARAMENTER LOGICAL ADDRESS PHYSICAL ADDRESS

Basic generated by CPU location in a memory unit

Logical Address Space is set

of all logical addresses Physical Address is set of all

Address generated by CPU in reference physical addresses mapped to the

Space to a program. corresponding logical addresses.


PARAMENTER LOGICAL ADDRESS PHYSICAL ADDRESS

User can view the logical User can never view physical

Visibility address of a program. address of program.

Generation generated by the CPU Computed by MMU

The user can use the logical

address to access the physical The user can indirectly access

Access address. physical address but not directly.

You might also like