Day 105 - Memory Segmentation

In the last post we learned that Paging is a part of the virtual memory that allows the OS to execede the limit of the physical memory by letting it draw blocks of data called pages from the secondary storage into the main memroy when needed for execution. Now we will be looking at segmentation.

What Is Segmentation?

Segmentation is a porcess that breaks a program into logical segments and allocates the space for these segemnts in the memory separately. The segments can be of many lengths and are more flexible. The programmer can use segments to tell the systems to bring certain data always together to the memory. The downside of segments is that they have to be managed by the programmer no matter what. Segmentation suffers from external fragmentation that is more difficult to deal with.

The systems having a paging memory management must handle the mapping of all the logical addresses to the physical addresses. In a paged environment, the user's view of the memory is very different from the system's view of memory. The user sees the memory as a collection of segments of different sizes of a program with no particular order in them.

For example the user will view one segment as the main program and other segment as some library routine etc. A user does not view the segment as a continous sequences of memory. Items in segments are addressed by their ofset from the base address such as the "10 line of code" etc.

The segmentation views the the logical space as a collection of segments where each segment has a name and a length which is an integer. Logical addresses are generated by the programmer and are transmitted to the Main Memory Unit by the CPU. They must specify both the segments name and the offset of the segment.

The paging system partitions the logical address into a page number and offset components. A logical address in a system using segmentation consists of a segment and an offset. The compiler generates object code that is associated with the segment of programmers original source code. The programmer must tell specifically to which a code segment belongs and the compiler will generate object code that reflects on these assignments.

Now a user has a two dimensional view of the memory. It is based on the logical addresses consisting of the segment and an offset. The system must map the two dimensional address to a single dimensional actual physical address in the main memory. It requires additional hardware support.


zainscizainsci