Social:Memory management (operating systems)

From HandWiki

In operating systems, memory management is the function responsible for managing the computer's primary memory.[1]:{{{1}}} The memory management function keeps track of the status of each memory location, either allocated or free. It determines how memory is allocated among competing processes, deciding which gets memory, when they receive it, and how much they are allowed. When memory is allocated it determines which memory locations will be assigned. It tracks when memory is freed or unallocated and updates the status.

This is distinct from application memory management, which is how a process manages the memory assigned to it by the operating system.

Memory management techniques

Single contiguous allocation

Single allocation is the simplest memory management technique. All the computer's memory, usually with the exception of a small portion reserved for the operating system, is available to a single application. MS-DOS is an example of a system that allocates memory in this way. An embedded system running a single application might also use this technique.

A system using single contiguous allocation may still multitask by swapping the contents of memory to switch among users. Early versions of the MUSIC operating system used this technique.

Partitioned allocation

Partitioned allocation divides primary memory into multiple memory partitions, usually contiguous areas of memory. Each partition might contain all the information for a specific job or task. Memory management consists of allocating a partition to a job when it starts and unallocating it when the job ends.

Partitioned allocation usually requires some hardware support to prevent the jobs from interfering with one another or with the operating system. The IBM System/360 used a lock-and-key technique. Other systems used base and bounds registers which contained the limits of the partition and flagged invalid accesses. The UNIVAC 1108 Storage Limits Register had separate base/bound sets for instructions and data. The system took advantage of memory interleaving to place what were called the i bank and d bank in separate memory modules.[2]

Partitions may be either static, that is defined at Initial Program Load (IPL) or boot time, or by the computer operator, or dynamic, that is, automatically created for a specific job. IBM System/360 Operating System Multiprogramming with a Fixed Number of Tasks (MFT) is an example of static partitioning, and Multiprogramming with a Variable Number of Tasks (MVT) is an example of dynamic. MVT and successors use the term region to distinguish dynamic partitions from static ones in other systems.[3]

Partitions may be relocatable using hardware typed memory, like the Burroughs Corporation B5500, or base and bounds registers like the PDP-10 or GE-635. Relocatable partitions are able to be compacted to provide larger chunks of contiguous physical memory. Compaction moves "in-use" areas of memory to eliminate "holes" or unused areas of memory caused by process termination in order to create larger contiguous free areas.[4]

Some systems allow partitions to be swapped out to secondary storage to free additional memory. Early versions of IBM's Time Sharing Option (TSO) swapped users in and out of time-sharing partitions.[5][lower-alpha 1]

Paged memory management

Main page: Virtual memory

Paged allocation divides the computer's primary memory into fixed-size units called page frames, and the program's virtual address space into pages of the same size. The hardware memory management unit maps pages to frames. The physical memory can be allocated on a page basis while the address space appears contiguous.

Usually, with paged memory management, each job runs in its own address space. However, there are some single address space operating systems that run all processes within a single address space, such as IBM i, which runs all processes within a large address space, and IBM OS/VS2 (SVS), which ran all jobs in a single 16MiB virtual address space.

Paged memory can be demand-paged when the system can move pages as required between primary and secondary memory.

Segmented memory management

Main page: Memory segmentation

Segmented memory is the only memory management technique that does not provide the user's program with a "linear and contiguous address space."[1]:165 Segments are areas of memory that usually correspond to a logical grouping of information such as a code procedure or a data array. Segments require hardware support in the form of a segment table which usually contains the physical address of the segment in memory, its size, and other data such as access protection bits and status (swapped in, swapped out, etc.)

Segmentation allows better access protection than other schemes because memory references are relative to a specific segment and the hardware will not permit the application to reference memory not defined for that segment.

It is possible to implement segmentation with or without paging. Without paging support the segment is the physical unit swapped in and out of memory if required. With paging support the pages are usually the unit of swapping and segmentation only adds an additional level of security.

Addresses in a segmented system usually consist of the segment id and an offset relative to the segment base address, defined to be offset zero.

The Intel IA-32 (x86) architecture allows a process to have up to 16,383 segments of up to 4GiB each. IA-32 segments are subdivisions of the computer's linear address space, the virtual address space provided by the paging hardware.[6]

The Multics operating system is probably the best known system implementing segmented memory. Multics segments are subdivisions of the computer's physical memory of up to 256 pages, each page being 1K 36-bit words in size, resulting in a maximum segment size of 1MiB (with 9-bit bytes, as used in Multics). A process could have up to 4046 segments.[7]

Rollout/rollin

Rollout/rollin (RO/RI) is a computer operating system memory management technique where the entire non-shared code and data of a running program is swapped out to auxiliary memory (disk or drum) to free main storage for another task. Programs may be rolled out "by demand end or...when waiting for some long event."[8] Rollout/rollin was commonly used in time-sharing systems,[9] where the user's "think time" was relatively long compared to the time to do the swap.

Unlike virtual storage—paging or segmentation, rollout/rollin does not require any special memory management hardware; however, unless the system has relocation hardware such as a memory map or base and bounds registers, the program must be rolled back in to its original memory locations. Rollout/rollin has been largely superseded by virtual memory.

Rollout/rollin was an optional feature of OS/360 Multiprogramming with a Variable number of Tasks (MVT)

Rollout/rollin allows the temporary, dynamic expansion of a particular job beyond its originally specified region. When a job needs more space, rollout/rollin attempts to obtain unassigned storage for the job's use. If there is no such unassigned storage, another job is rolled out—i.e., is transferred to auxiliary storage—so that its region may be used by the first job. When released by the first job, this additional storage is again available, either (1) as unassigned storage, if that was its source, or (2) to receive the job to be transferred back into main storage (rolled in).[10]

In OS/360, rollout/rollin was used only for batch jobs, and rollin does not occur until the jobstep borrowing the region terminates.

See also

Notes

  1. Known as TSO regions

References

  1. 1.0 1.1 Madnick, Stuart; Donovan, John (1974). Operating Systems. McGraw-Hill Book Company. ISBN 0-07-039455-5. https://books.google.com/books?id=74ZQAAAAMAAJ. 
  2. Sperry Rand (1970). UNIVAC 1108 Multi-processor System: System Description. p. 3-3. http://bitsavers.informatik.uni-stuttgart.de/pdf/univac/1100/UP-4046_1108mpSysDescr.pdf. 
  3. IBM Corporation (1970). IBM System/360 Operating System: Concepts and Facilities. p. 73. http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/os/R19_Jun70/GC28-6535-7_OS_Concepts_and_Facilities_Rel_19_Jun70.pdf. 
  4. Samanta, D. (2004). Classic Data Structures. PHI Learning Pvt. Ltd.. p. 94. ISBN 8120318749. https://books.google.com/books?id=_lDjLlasQycC&q=memory+compaction&pg=PA94. 
  5. IBM Corporation (1972). IBM System/360 Operating System Time Sharing Option Guide. pp. 10. http://www.bitsavers.org/pdf/ibm/360/os/tso/GC28-6698-5_Time_Sharing_Option_Guide_Jul72.pdf. (GC28-6698-5)
  6. Intel Corporation. IA-32 Intel Architecture Software Developer's Manual Volume 1: Basic Architecture. 
  7. Green, Paul. "Multics Virtual Memory – Tutorial and Reflections". http://ftp.stratus.com:80/pub/vos/multics/pg/mvm.html. Retrieved May 9, 2012. 
  8. Walraet, Bob (2014). Programming, The Impossible Challenge. Elsevier. p. 124. ISBN 978-0-444-87128-2. https://books.google.com/books?id=WLGjBQAAQBAJ&pg=PA124. Retrieved Aug 24, 2018. 
  9. "rollin/rollout" International Symposium on Computer Performance Modeling, Measurement, and Evaluation. Association for Computing Machinery. March 29–31, 1976. p. 137. https://books.google.com/books?id=XNhWAAAAMAAJ&q="rollin/rollout". Retrieved Aug 24, 2018. 
  10. IBM Corporation (June 1970). IBM System/360 Operating System: .Concepts and Facilities. p. 55. http://bitsavers.org/pdf/ibm/360/os/R19_Jun70/GC28-6535-7_OS_Concepts_and_Facilities_Rel_19_Jun70.pdf. Retrieved Aug 24, 2018.