Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Rweryguihiojop

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Comment

Memory Organization
The main purpose of a computer system is to execute programs. These programs,
together with the data they access, must be in main memory (at least partially)
during execution. To improve both the utilization of CPU and the speed of its
response to its users, the computer must keep several processes in memory.
There are many different memory-management schemes. Since main memory is
usually too small to accommodate all the data and programs permanently, the
computer system must provide secondary storage to back-up main memory.
Address mapping and translation

Most systems allow a user process to reside in any part of the physical memory.
(http://gradestack.com/mainsite/home)
Explore (/mainsite/explorecourse)
Memory Organization
Although the address space of the computer starts at 00000, the first address of
the user process does not need to be 00000. In most cases, a user program goes
through several steps before being executed. Addresses may be represented in
different ways during these steps. Addresses in the source program are generally
symbolic. A compiler typically binds these symbolic addresses to relocatable
addresses. The linkage editor or loader will in turn bind these relocatable
addresses to absolute addresses. Each binding is a mapping from one address
space to another. The addresses are translated using the relocation registers.

As in the diagram, the binding of instructions and data to memory can be done at
any step along the way:
Compile time: If it is known at compile time where the process will reside
in memory, then absolute code can be generated. For example, if it is
known a priori that a user process resides starting at location R, then the
generated compiler code will start at that location and extend up from
there. If, at some later time, the starting location changes, then it will be
necessary to recompile this code.
Load time: If it is not known at compile time where the process will reside
in memory, then the compiler must generate relocatable code. In this
case, final binding is delayed until load time. If the starting address
changes, we need only to reload the user code to incorporate this
changed value.
Execution time: If the process can be moved during its execution from
one memory segment to another, then binding must be delayed until run
rime.
Comment
Comment
Logical and physical addresses
An address generated by the CPU is commonly referred to as a logical address,
whereas an address seen by the memory unit, i.e., the one loaded into the
memory address register of the memory, is called physical address. The logical
address space may also be referred to as virtual address space. Now, since as
user we only see the logical address, but the system works with physical
addresses, some mapping must be done to allow correct working. This mapping
is done by the memory-management unit (MMU).

Base and Limit Registers
Base and limit registers are special registers in the system which are used by
MMU to convert logical addresses to physical addresses. Base register keep the
starting address of physical memory where the program resides where as the
limit register keeps the length of the program. These registers allow protecting
the OS code and data as well as a simpler model of executable (user) code. The
purpose of having base-limit register pairs is to address specific sub regions of
the memory unit.

Comment
Comment
Logical Address MMU Physical Address

The limitation of the base-limit register pair scheme of memory partitioning is
that the OS code has to fill in the actual memory address values in the registers
when a program is loaded. This implies that for every program to be loaded, the
OS has to manipulate certain references to memory addresses in the program.
Additional hardware support of physical address generation using a combination
of base register and the logical address generated by the CPU allows dynamic
relocation without the CPU overheads of physical address computation.
Memory management unit

A memory management unit (MMU) is a computer hardware component
responsible for handling accesses to memory requested by the central
processing unit (CPU). Its functions include translation of virtual addresses to
physical addresses, memory protection etc.
The MMU uses a base register also called relocation register. The value in this
register is added to the logical address, to get the physical address. That means,
depending on the value of the relocation register, the logical address is relocated
to its actual physical location.
Memory partitioning
The main memory must accommodate both the operating system and the various
user processes. The memory is usually divided into two partitions, one for the
resident operating system, and one for the user processes. If single partition
scheme is used, then we need to protect the operating-system code and data
from changes by the user processes and also protect the user processes from one
another. This can be done by loading the relocation and limit registers with the
correct values as part of the context switch.

For multiple partitions, one of the simplest methods is to divide memory into
several fixed-size partitions. Each partition may contain exactly one process.
Thus, the degree of multiprogramming is bound by the number of partitions. When
a partition is free, a process is selected from the input queue and is loaded into
the free partition. When the process terminates, the partition becomes available
for another process. Other method is to consider all memory as one large block, a
hole. When a process arrives and needs memory, we search for a hole large
enough for this process. If we find one, we allocate only as much memory as is
needed, keeping the rest available to satisfy future requests. Thus after some
time, there is at any time a set of holes, of various sizes, scattered throughout
memory. The operating system keeps a table indicating which parts of memory
are available and which are occupied.

The set of holes is searched to determine which hole is best to allocate. First-fit,
best-fit, and worst-fit are the most common strategies used to select a free hole
from the set of available holes.
Comment
Comment

Fragmentation
By partitioning the memory and allocating them using various strategies, the
memory is fragmented. Fragmentation can be internal and external. When fixed
size partitions are used, the process may or may not be the same size as the
partition. Thus, some amount of memory is left unused leading to internal
fragmentation.

When variable size partitions are used, problem of external fragmentation is
created as a lot of memory may still be available but since it is not contiguous, it
cannot be allotted to a process. The solution to the external fragmentation
problem is compaction. The goal is to shuffle the memory contents to place all
free memory together in one large block.

Previous
Deadlock
<
Next
Memory management techniques
>
Full Name
Email
Password
Contact Number
Account Already Exist?
Login Here (/web/login)
Facebook Connect
Create Account
mail us at contact@gradestack.com (mailto:contact@gradestack.com)
About Us (/mainsite/aboutus)

News (/mainsite/news)

Blog (/blog/)

Contact Us (/mainsite/contact)
Terms and Conditions (/mainsite/policy)

Developers (/mainsite/developer)

Publishers (/mainsite/publisher)
Please Register
f
or

You might also like