OS_CHAP6_alok
OS_CHAP6_alok
ADDRESS BINDING:
• User programs typically refer to memory addresses with symbolic names such as "i",
"count", and "temp" etc. These symbolic names must be mapped or bound to physical
memory addresses, which typically occurs in several stages:
.
LOGICAL VERSUS PHYSICAL ADDRESS SPACE:
• The address generated by the CPU is a logical address, whereas the address actually
seen by the memory hardware is a physical address.
SWAPPING:
• A process must be loaded into memory in order to execute.
• Swapping is a method in which the process should be swapped temporarily from the
main memory to the backing store. It will be later brought back into the memory for
continue execution.
• Backing store is a hard disk or some other secondary storage device that should be big
enough in order to accommodate copies of all memory images for all users. It is also
capable of offering direct access to these memory images.
Benefits of Swapping
Here, are major benefits/pros of swapping:
The main memory is divided into several fixed-sized partitions in a fixed partition memory
management scheme or static partitioning. These partitions can be of the same size or different
sizes. Each partition can hold a single process. The number of partitions determines the degree
of multiprogramming, i.e., the maximum number of processes in memory. These partitions are
made at the time of system generation and remain fixed after that.
Dynamic Partitioning
The dynamic partitioning was designed to overcome the problems of a fixed partitioning
scheme. In a dynamic partitioning scheme, each process occupies only as much memory as
they require when loaded for processing. Requested processes are allocated memory until the
entire physical memory is exhausted or the remaining space is insufficient to hold the
requesting process. In this scheme the partitions used are of variable size, and the number of
partitions is not defined at the system generation time.
1. External Fragmentation:
The total amount of free available primary is sufficient to reside a process, but can not be used
because it is non-contiguous. External fragmentation can be decreased by compaction or
shuffling of data in memory to arrange all free memory blocks together and thus form one
larger free memory block.
2. Internal Fragmentation:
Internal fragmentation occurs when the memory block assigned to the process is larger than
the amount of memory required by the process. In such a situation a part of memory is left
unutilized because it will not be used by any other process. Internal fragmentation can be
decreased by assigning the smallest partition of free memory that is large enough for allocating
to a process.
Now let’s suppose a P1 process of 3MB size arrives, and it is given a 4MB memory block.
Thus, as a result, the 1MB free space in this very block stays unused, and it can’t be used for
the allocation of memory to another process. It is called internal fragmentation.
PAGING:
• Paging is a fixed size partitioning scheme.
• For the page number generated by the CPU, Page Table provides the corresponding
frame number (base address of the frame) where that page is stored in the main
memory.The frame number combined with the page offset forms the required physical
address.
SEGMENTATION:
• Like Paging, Segmentation is another non-contiguous memory allocation technique.
• In segmentation, process is not divided blindly into fixed size pages.
• Rather, the process is divided into modules for better visualization.
Characteristics-
Segment Table: Segment table is a table that stores the information about each segment
of the process. It has two columns.
First column stores the size or length of the segment.
Second column stores the base address or starting address of the segment in the
main memory.
Segment table is stored as a separate segment in the main memory.
Segment table base register (STBR) stores the base address of the segment table.
If segment offset is found to be greater than or equal to the limit, a trap is generated.
If segment offset is found to be smaller than the limit, then request is treated as a
valid request.
The segment offset must always lie in the range [0, limit-1],
Then, segment offset is added with the base address of the segment.
The result obtained after addition is the address of the memory location storing the
required word.
SEGMENTED PAGING:
• Segmented paging is a scheme that implements the combination of segmentation and
paging.
• Process is first divided into segments and then each segment is divided into pages.
• These pages are then stored in the frames of main memory.
• A page table exists for each segment that keeps track of the frames storing the pages of
that segment.
• Each page table occupies one frame in the main memory.
• Number of entries in the page table of a segment = Number of pages that segment is
divided.
• A segment table exists that keeps track of the frames storing the page tables of segments.
• Number of entries in the segment table of a process = Number of segments that process
is divided.
• The base address of the segment table is stored in the segment table base register.