Non contiguous memory allocation methodology does require that a file be termed at the start. The file grows as needed with time. A major advantage is the reduced waste of disk space and flexibility when it comes to memory allocation. The Operating System will allocate memory to the file when needed.
Non contiguous memory allocation, offers the following advantages over contiguous memory allocation:
-
Allows the interdependence of code and data among processes.
-
External fragmentation is none existent with non contiguous memory allocation.
-
Virtual
memory allocation is strongly supported in non contiguous memory
allocation.
Paging
External fragmentation is avoided by using paging technique. Paging is a technique in which physical memory is broken into blocks of the same size called pages (size is power of 2, between 512 bytes and 8192 bytes). When a process is to be executed, it's corresponding pages are loaded into any available memory frames.Logical address space of a process can be non-contiguous and a process is allocated physical memory whenever the free memory frame is available. Operating system keeps track of all free frames. Operating system needs n free frames to run a program of size n pages.
Address generated by CPU is divided into
-
Page
number (p) -- page number is used as an index into a page table
which contains base address of each page in physical memory.
-
Page
offset (d) -- page offset is combined with base address to
define the physical memory address.
Some of the advantages and disadvantages of paging are:advantages: -
Paging Eliminates Fragmentation
-
Multiprogramming is supported
-
Overheads that come with compaction during relocation are eliminateddisadvantages :
-
Paging increases the price of computer hardware, as page addresses are mapped to hardware
-
Memory is forced to store variables like page tables
-
Some
memory space stays unused when available blocks are not sufficient
for address space for jobs to run
Segmentation
Segmentation is a technique to break memory into logical pieces where each piece represents a group of related information. For example ,data segments or code segment for each process, data segment for operating system and so on. Segmentation can be implemented using or without using paging.
Unlike paging, segment are having varying sizes and thus eliminates internal fragmentation. External fragmentation still exists but to lesser extent.
Address generated by CPU is divided into
-
Segment
number (s) -- segment number is used as an index into a segment
table which contains base address of each segment in physical memory
and a limit of segment.
Segment offset (o) -- segment offset is first checked against limit and then is combined with base address to define the physical memory address.
Some of the advantages and disadvantages of segmentation are:advantages: -
Fragmentation is eliminated in Segmentation memory allocation
-
Segmentation fully supports virtual memory
-
Dynamic memory segment growth is fully supported
-
Segmentation supports Dynamic Linking
-
Segmentation
allows the user to view memory in a logical sense.
disadvantages of segmentation: -
Main memory will always limit the size of segmentation, that is, segmentation is bound by the size limit of memory
-
It is difficult to manage segments on secondary storage
-
Segmentation is slower than pagingSegmentation falls victim to external fragmentation even though it eliminates internal fragmentation
No comments:
Post a Comment