Operating System: Primary Memory Management; Swapping; Paging; Segmentation

 


Memory Management

Relocation, Protection and Sharing

  What is relocation?

 Relocation is the process of moving a process. Code and data around in main memory without having to recompile. In other words, relocation refers to the ability to load and execute a given program into an arbitrary in memory, ad opposed to fixed set to locations specified at program translation time.


    What do you mean by protection and sharing?

 We need to protect the monitor co=de and data from chafes by the user program. This protection must be provided by the hardware and can be implemented in several ways. Memory management strategies must implement in several ways. Memory management strategies must implement of some form. Process should only access memory they are allowed to.

Sharing: A good memory management mechanism must also provide for controlled sharing of data and code between cooperation process. Processes which are executing the same program should be able to share code. Process may also wish to share data.


Swapping

Allocation algorithms:

i)                   First fit
ii)                 Best fit
iii)               Worst fit

The most common algorithms for allocation memoty is as follows:

Strategies
 Explanation
Best fit

First fit

Worst fit  
Job placed iv hole which is closest to job size.

Job is placed iv first hole it can fit it.

A job is placed into the largest possible hole.

Swapping



 Swapping has traditionally been used to implement multiprogramming in a system with restrictive memory capacity or with little hardware support for memory management. Removing suspended or preempted processes from memoty and their subsequent bringing back (disk or drum) is called swapping.

Problems in fixed partitions and how to solve this?

 A swapping system could be based in fixed partitions. Whenever a job is blocked, it could be moved to the disk and another job brought into its partition from disk. Actually, fixed partitions are unattractive when memory is scarce because too much of it is wasted by programs that are smaller than their partitions.
The another problem with MFT is determining the best partition sizes to minimize internal and external fragmentation. The solution to this problem is to allow the region sized to vary dynamically. This approach is called multiple contiguous variable partition allocation.

Internal fragmentation:

 A job needs p words of memory may be run in a region or partition e.g. words, where q≥p . the difference between these two numbers (q-p) is internal fragmentation, memory which is internal to a region.

 Explain how to implement variable partition?

The operating system keeps a table of memory hole. Memory hole is the sections of  RAM not currently being used, the memory hole can be contiguous or noncontiguous. When a job enters the system it is allocated exactly the amount of memory it needs from memory hole. When finishes it returns its used memory to memory hole.

Paging

Paging , page frame ad pages:

 Paging is a memory-management scheme that removes the requirement of contiguous allocation of physical memory, address mapping id used to maintain the illusion of contiguity of the logical address space of a job despite its discontinuous placements in physical memory.

The physical memory is conceptually sivided into a numver of fixed-sized slots, called page frames. The logical-address apace of a process os also aplit into oxed-size clocks of the same size, called pages.


Segmentation


segment and segmentation

 A segment is a grouping of information that is treated as an entity. This may be one or many programs, a subroutine, function, symbol table.

Segmentation: Segmentation is the process of dividing up a program that is to be run into a number of segments of different sizes and placing these chunks in logical memory wherever they fit.


List some of the advantages of segmentation scheme.

Segmentation has a number of advantages to the programmer over a non segmented address space:
i)                   It simplifies the handling of growing data structures.
ii)                 It allows programs to be altered and recompiles independently, without requiring that an entire set of programs be re-linked and reloaded.
iii)               It lends itself to sharing among job.
iv)               It lends itself to protection.


  The disadvantages of this scheme:
 i) Since the words of each segment must be contiguous, fragmentation can be a major problem, especially if segments are allowed to dynamically grow.
ii) The size of the total address space is limited by the size of physical  memory.

How to combat the inefficiency of paging and segmentation?

In an effort to combat the inefficiency inherent in both of these processes, a combination of segmentation and paging is frequently used t minimize the amount of wasted space in memory or to improve on each. In this combined process, a program is first broken into segments and then the segment and page tables are needed to keep track of the various programs pieces, which increases the complexity with which the operating system must deal. The IBM 360/67 was an early segmented paging system.

Virtual Memory Concept

Virtual memory:

Virtual memory describes a set of techniques that allow us to execute a program which is entirely in memory.
Virtual memory is a technique which allows the execution of processes that may not be completely in memory. The main visible advantage of this scheme is that user programs can be larger than physical memory.

Page replacement
Page replacement is basic to demand paging. It completes the separation between logical memory and physical memory.

Comments