Deadlock: Difference between revisions
No edit summary |
|||
Line 27: | Line 27: | ||
Instead of having one overlay area what if we had many? | Instead of having one overlay area what if we had many? | ||
[[Image: | [[Image:Diagram3_c3.jpeg]] | ||
This is primitive because programming manually has to manage memory in addition to being inefficient. How do you deal with the situation so that you don’t need to deal with it every again? | This is primitive because programming manually has to manage memory in addition to being inefficient. How do you deal with the situation so that you don’t need to deal with it every again? |
Revision as of 03:21, 13 November 2007
(Currently UNDER CONSTRUCTION!)
Memory Management & Virtual Memory
Swapping
A memory management technique where a process may periodically have its primary memory space deallocated. This forces the swapped-out process to compete for memory before it can once again compete for the processor
Swapping is especially well suited to timesharing systems since such systems often have times when a user logs onto the machine but is inactive for relatively long periods ( and hence not using the CPU).
Overlays
Significant problem with overlays is when exactly do you load x, y or z. We have to make sure they are there. Developers need to think carefully what they put in these modules. Another problem with swapping is that x, y, and z can’t talk to each other , they need some sort of cut / paste buffer. The problem is that x, y and z are different sizes and we need to fit the biggest one in the overlay area.
X,Y and Z are all desired to be loaded in the same area of RAM. In traditional overlay schemes this would be an index.
Classic problem of memory management: Fragmentation, difference between size of overlay area and size of the overlays
Instead of having one overlay area what if we had many?
This is primitive because programming manually has to manage memory in addition to being inefficient. How do you deal with the situation so that you don’t need to deal with it every again? First step is to change this and to add relocation. To do that we need to have some sort of indirection
Fragmentation
- Data fragmentation
Reduces the amount of fragmentation in file systems. Occurs when a piece of data in memory is broken up into many pieces. Two types of fragmentation which exist are internal fragmentation and external fragmentation
- Internal Fragmentation
Space is wasted in return for increased efficiency or simplicity. An example is that many file systems files always start at the beginning of a sector, which simplifies organization and makes it easier to grow files. Any space that is left over between the last byte of the file and the first byte of the next sector is internal fragmentation. Internal fragmentation occurs when the index pages are not being used to their maximum volume
- External Fragmentation
In such a fragmentation, the free space which is available for storage is divided into many small pieces. The storage space is of many different sizes.
- Page
fixed-length block of main memory, that is contiguous in both physical addressing and virtual memory addressing.
Memory Segmentation
Technique used to divide memory into smaller units. It is an extension of the ideas suggested by the use of relocation-limit registers for relocating and bound checking blocks of memory. Memory contents are referenced using a two-component virtual address <segmentNumber, offset> . Segment number identifies the particular logical block of memory and offset is a linear offset from the beginning of the segment. Segmentation provides more programmer control over the units of transfer in the memory system than paging does. Memory segments are distinct from memory pages because the segments are usually much larger than pages, and can be of a variable size.
Paging
Thisis an allocation strategy in a paging system to reduce external fragmentation by transferring a fixed-size unit of virtual address space(page) whenever a virtual address in it is needed to execute the program. Every process’s virtual address space is logically divided into pages, with each page having the same number of location.
The program translation image is constructed to fit in a set of G continguous memory locations, with virtual addresses ranging between 0 and G-1. When the process executes it is allocated enough primary memory to store the contents of H memory locations where H<G (that is the process has fewer physical memory locations than virtual addresses)
In a binary computer the paging system maps the virtual addressees in the absolute module (0-G) into a set of n = 2^g pages, each of size c = 2^h. If G is not an integer multiple of the page size then part of the last page will be lost to internal fragmentation; the paging system will adjust G upward to hold the entire virtual address space.
Physical address space is the portion of the primary memory allocated to the process. The units of allocation are page frames and these are blocks of primary memory which are the same size as the page. The physical address space can be though of as a set of m = 2^j page frames each of size c = 2^h, so the amount of primary memory allocated to the process is H = 2^(h+j)
Paging Algorithms
There are two basic types of pagig algorithms: static and dynamic allocation
Static Paging algorithms
allocates a fixed number of page frames to a process when it is created. The paging policy defines hwo tehse page frames will be loaded and unloaded by the virtual memory system three basic policies in defining paging algorithm are fetch policy: when a page should be loaded into memory
replacement policy: determines which page should be removed from primary memory if all page frames are full
placement policy: determines where the fetched page whould be loaded into primary memory
Dynamic Paging algorithms
Dynamic paging algorithms adjust the memory allocation to match the process's needs as they change.