Memory Management
Paging
§ Logical address space of a process can be noncontiguous process is allocated physical memory whenever the latter is available
§ Divide physical memory into fixed-sized blocks called frames(size is power of 2, between 512 bytes and 8,192 bytes)
§ Divide logical memory into blocks of same size called pages
§ Keep track of all free frames
§ To run a program of size n pages, need to find n free frames and load program
§ Set up a page table to translate logical to physical addresses
§ Internal fragmentation
Paging Example
Segmentation
§ Memory-management scheme that supports user view of memory
§ A program is a collection of segments. A segment is a logical unit such as:
® main program,
® procedure,
® function,
® method,
® object,
® local variables,
® global variables,
® common block,
® stack,
® symbol table,
® arrays
§ Logical address consists of a two tuple:
<segment-number, offset>,
§ Segment table – maps two-dimensional physical addresses;
each table entry has:
§ base – contains the starting physical address where the
segments reside in memory
§ limit – specifies the length of the segment
§ Segment-table base register (STBR)points to the segment
table’s location in memory
§ Segment-table length register (STLR)indicates number of
segments used by a program;
segment number s is legal if s< STLR
Protection
§ With each entry in segment table associate:
® validation bit = 0 Þ illegal segment
® read/write/execute privileges
§ Protection bits associated with segments code sharing occurs at segment level
§ Since segments vary in length, memory allocation is a dynamic storage-allocation problem
§ A segmentation example is shown in the following diagram
No comments:
Post a Comment