Memory Management Techniques: Swapping, Contiguous Allocation, Paging, and Segmentation, Study notes of Operating Systems

Learn some concepts of operating system=>Memory Management.

Typology: Study notes

2015/2016

Uploaded on 06/09/2016

James.Paul
James.Paul 🇹🇿

1 document

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
GROUP ASSIGNMENT
COURSE: BACHELOR OF COMPUTER SCIENCE
MODULE: OPERATING SYTEM CONCEPTS
SEMISTER: TWO
FACILITATOR: ALLAN MSOLA.
PARTICIPANTS:-
NAMES
REGISTRATION NUMBERS;
1. MTUI James P.
BCS/0172/T.2015
2. MWENDA Nuhu A.
BCS/0159/T.2015
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Memory Management Techniques: Swapping, Contiguous Allocation, Paging, and Segmentation and more Study notes Operating Systems in PDF only on Docsity!

GROUP ASSIGNMENT

COURSE: BACHELOR OF COMPUTER SCIENCE

MODULE: OPERATING SYTEM CONCEPTS

SEMISTER: TWO

FACILITATOR: ALLAN MSOLA.

PARTICIPANTS:-

NAMES REGISTRATION NUMBERS;

**1. MTUI James P. BCS/0172/T.

  1. MWENDA Nuhu A. BCS/0159/T.**

1. SWAPPING

As noted by Silberschatz, Galvin & Gagne (2011) , that swapping is the useful technique that enables the computer to execute programs and manipulate data files larger than main memory. They argue again, A process must be in memory to be executed. A process, however, can be swapped temporarily out of memory to a backing store and then brought back into memory for continued execution. For example, assume a multiprogramming environment with a round-robin CPU-scheduling algorithm. When a quantum expires, the memory manager will start to swap out the process that just finished and to swap another process into the memory space that has been freed. In the meantime, the CPU scheduler will allocate a time slice to some other process in memory. When each process finishes its quantum, it will be swapped with another process. Ideally, the memory manager can swap processes fast enough that some processes will be in memory, ready to execute, when the CPU scheduler wants to reschedule the CPU. In addition, the quantum must be large enough to allow reasonable amounts of computing to be done between swaps. A variant of this swapping policy is used for priority-based scheduling algorithms. If a higher-priority process arrives and wants service, the memory manager can swap out the lower- priority process and then load and execute the higher-priority process. When the higher-priority process finishes, the

process with pending I/O, or execute I/O operations only into operating-system buffers. Transfers between operating-system buffers and process memory then occur only when the process is swapped in.

2. CONTIGUOUS MEMORY ALLOCATION.

As identified by TECHNOPEDIA ( 2016 ), Contiguous memory allocation is a classical memory allocation model that assigns a process consecutive memory blocks (that is, memory blocks having consecutive addresses). Contiguous memory allocation is one of the oldest memory allocation schemes. When a process needs to execute, memory is requested by the process. The size of the process is compared with the amount of contiguous main memory available to execute the process. If sufficient contiguous memory is found, the process is allocated memory to start its execution. Otherwise, it is added to a queue of waiting processes until sufficient free contiguous memory is available. When refer to Silberschatz, Galvin & Gagne (2011), They said, main memory must accommodate both the operating system and the various user processes. We therefore need to allocate main memory in the most efficient way possible. This section explains one common method, contiguous memory allocation. The memory is usually divided into two partitions: one for the resident operating system and one for the user processes. We can place the operating system in either low memory or high memory. The major factor affecting this decision is the location of the interrupt vector. Since the interrupt vector is often in low memory, programmers usually place the operating system in low memory as well. Thus, in this text, we discuss only the situation in which the operating system resides in low memory. The development of the other situation is similar. We usually want several user processes to reside in memory at the same time. We therefore need to consider how to allocate available memory to the processes that are in the input queue waiting to be brought into memory.

3. PAGING. “Paging is a memory-management scheme that permits the physical address space of a process to be noncontiguous. Paging avoids external fragmentation and the need for compaction. It also solves the considerable problem of fitting memory chunks of varying sizes onto the backing store; most memory management schemes used before the introduction of paging suffered from this problem. The problem arises because, when some code fragments or data residing in main memory need to be swapped out, space must be found on the backing store.

The backing store has the same fragmentation problems discussed in connection with main memory, but access is much slower, so compaction is impossible. Because of its advantages over earlier methods,

paging in its various forms is used in most operating systems.” (Silberschatz, Galvin & Gagne. 2011, (305-307)).

Traditionally, support for paging has been handled by hardware. However, recent designs have implemented paging by closely integrating the hardware and operating system, especially on 64-bit microprocessors.

4. STRACTURE OF THE PAGE TABLE. As suggested by Ahsen (2012), explore some of the most common techniques for structuring the page table. As following-: i. Hierarchical paging/Multilevel Paging. Most modern computers support a large logical address space: (232 to 264). In such an Environment, the page table itself becomes excessively large. Consider the following Example: 􀀀 Logical address = 32-bit 􀀀 Page size = 4K bytes (212 bytes) 􀀀 Page table entry = 4 bytes 􀀀 Maximum pages in a process address space = 232 / 4K = 1M

ii. Hashed Page Tables.

This is a common approach to handle address spaces larger then 32 bits .Usually open hashing is

used. Each entry in the linked list has three fields: page number, frame number for the page, and

pointer to the next element—(p, f, next). The page number in the logical address (specified by p)

is hashed to get index of an entry in the hash table. This index is used to search the linked list

associated with this entry to locate the frame number Corresponding to the given page number.

The advantage of hashed page tables is smaller page tables.

B). two views of address translation for a two-level paging architecture

iii. Inverted Page Table.

Usually each process has a page table associated with it. The page table has one entry for each

page in the address space of the process. For large address spaces (32-bit and above), each page

table may consist of millions of entries. These tables may consume large amounts of physical

memory, which is required just to keep track of how the mapping of logical address spaces of

processes onto the physical memory.

A solution is to use an inverted page table. An inverted page table has one entry for each real

page (frame) of memory. Each entry consists of the virtual address of the page stored in the in

that real memory location, with information about the process that own the page. Page table size

is limited by the number of frames (i.e., the physical memory) and not process address space.

Each entry in the page table contains (pid, p). If a page ‘p’ for a process is loaded in frame ‘f’, its

entry is stored at index ‘f’ in the page table. We effectively index the page table with frame

number; hence the name inverted page table. Examples of CPUs that support inverted pages

tables are 64-bit Ultra SPARC and PowerPC. The following diagram shows how logical

addresses are translated into physical addresses.

Address translation with invited page table.

REFERENCES.

SILBERSCHATZ, A., GALVIN, P. & GAGNE, G., (2002) Operating system Concepts essentials. Jefferson City: R.R Donelley.

AHSEN, P. (2012) Operating system Activities. [Online] Sterling: docsity Page. Available from: http://www.docsity.com/en/Structure_of_the_Page_Table_-Introduction_to_Operating_System- Lecture_Notes/204004. [Accessed: 6/3/2015].

TECHNOPEDIA™, (2007) Contiguous memory allocation. [Online] June 24th 2007. TECHNOPEDIA™ Discussion List. Available from: http:// www.techopedia.com/definition/3769/contiguous-memory-allocation [Accessed: 3rd^ June 2016].