Sabtu, 09 Juni 2012

MEMORY MANAGEMENT



The needs of users can be met best by a computing environment that supports modular
programming and the flexible use of data. System managers need efficient and
orderly control of storage allocation.The OS, to satisfy these requirements, has five
principal storage management responsibilities:

Process isolation: The OS must prevent independent processes from interfering
with each other’s memory, both data and instructions.
Automatic allocation and management: Programs should be dynamically allocated
across the memory hierarchy as required. Allocation should be transparent
to the programmer. Thus, the programmer is relieved of concerns relating
to memory limitations, and the OS can achieve efficiency by assigning memory
to jobs only as needed.
Support of modular programming: Programmers should be able to define
program modules, and to create, destroy, and alter the size of modules
dynamically.
Protection and access control: Sharing of memory, at any level of the memory
hierarchy, creates the potential for one program to address the memory space
of another.This is desirable when sharing is needed by particular applications.
At other times, it threatens the integrity of programs and even of the OS itself.
The OS must allow portions of memory to be accessible in various ways by
various users.
Long-term storage: Many application programs require means for storing information
for extended periods of time, after the computer has been powered
down.

Typically, operating systems meet these requirements with virtual memory and
file system facilities.The file system implements a long-term store, with information
stored in named objects, called files. The file is a convenient concept for the programmer
and is a useful unit of access control and protection for the OS.

Virtual memory is a facility that allows programs to address memory from a
logical point of view, without regard to the amount of main memory physically
available.Virtual memory was conceived to meet the requirement of having multiple
user jobs reside in main memory concurrently, so that there would not be a hiatus
between the execution of successive processes while one process was written
out to secondary store and the successor process was read in. Because processes
vary in size, if the processor switches among a number of processes, it is difficult to
pack them compactly into main memory. Paging systems were introduced, which
allow processes to be comprised of a number of fixed-size blocks, called pages. A
program references a word by means of a virtual address consisting of a page number
and an offset within the page. Each page of a process may be located anywhere
in main memory. The paging system provides for a dynamic mapping between the
virtual address used in the program and a real address, or physical address, in main
memory.

With dynamic mapping hardware available, the next logical step was to eliminate
the requirement that all pages of a process reside in main memory simultaneously.
All the pages of a process are maintained on disk. When a process is
executing, some of its pages are in main memory. If reference is made to a page that
is not in main memory, the memory management hardware detects this and
arranges for the missing page to be loaded. Such a scheme is referred to as virtual
memory and is depicted in Figure 1.

The processor hardware, together with the OS, provides the user with a “virtual
processor” that has access to a virtual memory.This memory may be a linear address
space or a collection of segments, which are variable-length blocks of contiguous addresses.
In either case, programming language instructions can reference program
and data locations in the virtual memory area. Process isolation can be achieved by
giving each process a unique, nonoverlapping virtual memory. Memory sharing can
be achieved by overlapping portions of two virtual memory spaces. Files are maintained
in a long-term store. Files and portions of files may be copied into the virtual
memory for manipulation by programs.

Operating Systems
 Figure 1. Virtual Memory Concepts

Figure 2 highlights the addressing concerns in a virtual memory scheme.
Storage consists of directly addressable (by machine instructions) main memory
and lower-speed auxiliary memory that is accessed indirectly by loading blocks into
main memory. Address translation hardware (memory management unit) is interposed
between the processor and memory. Programs reference locations using virtual
addresses, which are mapped into real main memory addresses. If a reference is
made to a virtual address not in real memory, then a portion of the contents of real
memory is swapped out to auxiliary memory and the desired block of data is
swapped in. During this activity, the process that generated the address reference
must be suspended.The OS designer needs to develop an address translation mechanism
that generates little overhead and a storage allocation policy that minimizes
the traffic between memory levels.

Figure 2. Virtual Memory Addressing

Source :
"Fifth Edition Operating Systems : internal and design principles".
By William Stallings





















0 komentar:

Posting Komentar