Silvio Neris (master of disaster)

you are my visitor number since March 5, 1998

Memory manager

The management of main memory is critical. In fact, the performance of the entire system has historically been directly dependent on two things: how much memory is available and how it is optimized while jobs are being processed.

Early Systems

I'm going to introduce four types of memory allocation schemes that were used in early systems: fixed partitions, dynamic partitions, and relocatable dynamic partitions.

Fixed Partitions

In this scheme each program to be processed was loaded entiretly into memory and allocated in as much contiguous space in memory as it needed. Also in this scheme, RAM is divided (logically) into partitions and the size of each of them are setup at boot up. Partitions sizes can be reconfigured but you have to reboot for the effects to take place. The other way we can have fixed partitions is to allow these partitions to vary in size. There is a problem with this type of memory allocation scheme and is that it creates internal fragmentation. This is how it happens: Suppose you have 200kb of memory and it is devided into 4 fixed 50kb partitions. And you want to load 4 jobs (programs or data) of 45kb each. Each partition is going to have 5kb of space remaining. Now you want to load a 20kb job into memory. This job cannot be loaded because jobs have to be contiguous.

Dynamic Partitions

With this scheme contiguous jobs still load in entirety. But now the jobs are given as much space as they want if it is available. In this scheme partitions are not fixed. This scheme however, creates external fragmentation. Suppose you have 100kb of memory and you load 2 50kb jobs. You do not have external fragmentation yet but suppose you finish using one of the two jobs and now you load a 45kb job into memory. This job will take the memory it requests out of 50kb and leaves the other space alone. Now you have a 50kb job and a 45kb job with 5kb of memory space between them. This is called external fragmentation.

Relocatable Dynamic Partitions

This scheme is like dynamic partitions but combined with defragmentation which combines free blocks of memory every now and then into one large block. This solves the problem of external fragmentation.


Recent Systems

We will look at memory allocation schemes used by modern OSs that eliminates one or both of the previous loading requirements.

They are:

(1)Paged memory model
(2)Demand paging memory model
(3)Segmented memory model
(4)Segmented/Demand Paged memory model


Paged memory model

In this model we take care of contiguity by allowing parts of one program to reside in different blocks in main memory called page frames. These frames are all of the same size. A program is divided into equal sized pages, which are then placed in available page frames. Remember that in these model programs are divided into pages of equal sizes and memory is divided into page frames also of equal sizes.

Splitting up a program obviously means a bigger managerial overhead because the system now has to remember where each page of the program is. There are 3 system tables which help the OS keep track of jobs and their frames:

(1)Job Table--It keeps track of which jobs are loaded and where their tables are.

(2)The Page Map Table--there is one for each job and it contains information concerning where each page is on memory.

(3)The Memory Map Table--Keeps track of every main memory frame and whether is occupied or not.


Demand Paging

This model is similar to paging but now not all pages of a program need to be in memory.

In this model you need information concerning the use of a frame. To prevent a modified frame from not being save on disk the system also keeps track of whether the page on that frame was modified or not. The process of moving pages in and out is called swapping. When there is a constant swapping of pages back and forth resulting in tremendous disk activity. This is called thrashing.When an address is generated for a page that is not in memory it is referred to as a page fault.

The popular replacement stragedies are:

(1)First-in First-out (FIFO)
(2)Least Recently Used (LRU)


Segmented memory allocation

In this model each job is divided into several segments of different sizes.


note: Pages are of same sizes and segments are of different sizes.

Memory are no longer divided into frames and allocated in dynamic manners. The system needs a segment map table for each job. This table is needed to keep track of segment sizes as well as addresses of each table. Segmented memory allocation causes fragmentation so compaction is necessary.


Segment/Demand Paged memory allocation

Segments in this scheme are broken into pages of equal size. You need to keep track of where each segment is with a segment map table. Each entry in this table points a page map table, which tells you which pages are loaded or not and where they are.

THIS PAGE IS UNDER CONSTRUCTION


HOME

If you have any comments, questions or suggestions simply e-mail Silvio Neris(the master of disaster)