Professional Documents
Culture Documents
• Primary memory holds only those data and instructions on which the
computer is currently working. It has a limited capacity and data is
lost when power is switched off. It is generally made up of
semiconductor device. These memories are not as fast as registers.
The data and instruction required to be processed resides in the
main memory. It is divided into two subcategories RAM and ROM
RAM vs ROM
Characteristics of Main Memory
• Time???
Advantages of Swapping
1.If the computer system loses power, the user may lose all information
related to the program in case of substantial swapping activity.
2.If the swapping algorithm is not good, the composite method can
increase the number of Page Fault and decrease the overall processing
performance.
WHAT DOES MAIN MEMORY DO?
• Main memory’s job is to hold data that the CPU needs to
access frequently, such as instructions and data currently being
processed. Data can be accessed much more quickly than data
stored on disk Drives or other secondary storage
devices. Instructions are read into the CPU by an instruction
fetch unit, decoded by an instruction decode unit, and executed
by one or more execution units within the CPU.
WHERE DID THE TERM COME FROM?
• The term was coined by IBM engineer George Scalise in 1956 when he
designed RAMAC (Random Access Method of Accounting and Control), the
first commercial computer with a hard disk drive. In early computers, all
processing took place in the main memory because there was no hard disk
drive for long-term storage of programs and data.
• Because computers often have too little main memory to hold all the data they
need, computer engineers invented a technique called swapping, in which portions
of data are copied into main memory as they are needed. Swapping occurs when
there is no room in memory for needed data. When one portion of data is copied
into memory, an equal-sized portion is copied (swapped) out to make room.
Contiguous Allocation
• Main memory must support both OS and user processes
• Limited resource, must allocate efficiently
• Contiguous allocation is one early method
• Main memory usually into two partitions:
• Resident operating system, usually held in low memory with interrupt vector
• User processes then held in high memory
• Each process contained in single contiguous section of memory
Contiguous Allocation (Cont.)
• Relocation registers used to protect user processes from each
other, and from changing operating-system code and data
• Base register contains value of smallest physical address
• Limit register contains range of logical addresses – each logical address
must be less than the limit register
• MMU maps logical address dynamically
• Can then allow actions such as kernel code being transient and kernel
changing size
Hardware Support for Relocation and Limit Registers
Multiple-partition allocation
• Multiple-partition allocation
• Degree of multiprogramming limited by number of partitions
• Variable-partition sizes for efficiency (sized to a given process’ needs)
• Hole – block of available memory; holes of various size are scattered throughout memory
• When a process arrives, it is allocated memory from a hole large enough to accommodate it
• Process exiting frees its partition, adjacent free partitions combined
• Operating system maintains information about:
a) allocated partitions b) free partitions (hole)
Dynamic Storage-Allocation Problem
How to satisfy a request of size n from a list of free holes?
First-fit and best-fit better than worst-fit in terms of speed and storage
utilization
Fragmentation
• External Fragmentation – total memory space exists to
satisfy a request, but it is not contiguous
• Internal Fragmentation – allocated memory may be slightly
larger than requested memory; this size difference is
memory internal to a partition, but not being used
• First fit analysis reveals that given N blocks allocated, 0.5 N
blocks lost to fragmentation
• 1/3 may be unusable -> 50-percent rule
Fragmentation (Cont.)
4
1
3 2
4