Memory Management (week 8) Flashcards
what are the 2 types of memory in the computer system
primary memory and secondary memory
primary memory holds __________
information while the CPU is using it
secondary memory stores ___________
information in storage devices while CPU is NOT using it
who is responsible for allocating and deallocating primary memory
memory manager
memory manager ensures that the memory is _______________
not abused and is used efficiently.
system calls with respect to the use of memory is found in ________ os
windows and unix
what are the requirements of memory manager
–> Minimize executable memory access time
–> Maximize executable memory size
–> Executable memory must be cost effective
what does the memory manager do ?
–> Allocates primary memory to processes
–> Maps process address space to primary
memory
–> Minimizes access time using cost-effective memory configuration
–> May use static or dynamic techniques
how is it like at the top and bottom of the storage hierarchy
At the top of the hierarchy is faster, but more expensive memory, e.g., registers (more frequently used)
At the bottom is slower, but cheaper memory, e.g., hard disk, tape drives. (less frequently used)
why is there a need to attach addresses to every single instruction in the program When a program is converted (compiled)
into executable form
–> Program instructions need to be stored in a particular order in order for the CPU to execute in the correct way.
–> Programs involve many ‘jumps’ to different parts of the program. In order to do this, there has to be a concept of addresses for every part of the program.
what is address binding
the process of attaching addresses to every single instruction of the program when the program is being compiled into executable form is called address binding
how to create an executable program
–> compile time: source code is converted to object code
–> link time: after compilation, there is a need to link it with the libraries. This executable file is stored in secondary storage devices
–> load time: When the executable file is run it is loaded into the RAM, where primary memory is allocated then the addresses are adjusted in address space where finally the address space is copied from secondary memory to primary memory
what are 3 ways to ensure that when a
program is loaded up into memory, each
instruction has an address. (types of address bindings)
compile time binding
load time binding
run time binding
how does compile time binding work ?
–> Addresses are attached to each instruction when program is compiled.
–> Program is loaded into same location in
memory whenever it is executed.
–> Cannot be relocated into different locations in memory.
–> good for single memory systems like ms dos
what is load time binding
–> During compilation, the program is attached with relocatable addresses. E.g., start at 0x0000.
–> When program is loaded into memory, the location of the first instruction is loaded into a special register
–> To access the program, take re-locatable address of instruction + value of special register
–> Once loaded into memory, the program cannot be relocated into another portion of the memory.
what is run time binding
–> Address binding is delayed until run-time
–> Similar in concept to load time binding, i.e., using a relocatable register.
–> Address of instruction is calculated only when the instruction is required.
–> Very flexible as program can be relocated into any portion of memory at any time.
–> Used by modern OS for multi programming.
what is logical address
it is the address which is generated by the CPU also called virtual address
what is physical address
it is the address as seen by the memory unit
when are logical addresses and compile time addresses the same
in compile-time and load-time address-binding schemes.
when are logical addresses and compile time addresses different
differ in run-time address-binding scheme.
set of all logical addresses is referred to as ____________
logical
address spaces
set of all physical addresses is referred to as
physical address spaces
what are the 3 strategies memory allocation
fixed partition
variable partition
what is fixed partition
–> Primary memory is divided into a fixed number of fixed-size blocks/partitions
–> partitions are not of fixed size (most of the time)
–> prone to internal fragmentation
what is variable partition
–> Memory is allocated to processes on a need-to and available basis
–> Use dynamically determined, variable-sized blocks
–> prone to external fragmentation
–> requires run time address binding to resolve fragmentation problems
what is fragmentation
Ideally, the memory manager could allocate every single byte of memory to a process if any process needs memory.
However, in practical terms, parts of the memory, called memory fragment, cannot be used at any given time because memory manager is unable to allocate these parts in an efficient manner.
2 types of fragmentation
internal fragmentation
external fragmentation
when does internal fragmentation occur
Internal fragmentation occurs when memory is divided into fixed sized blocks and allocated in blocks. Leftover space within a partition after process allocation is unavailable for use until the process is completed and the memory partition is released.
when does external fragmentation occur
External fragmentation is caused due to dynamic memory allocation in blocks of different sizes according to process sizes. Over time, many small separate blocks will be created due to processes being added and terminated.
can internal and external fragmentation occur together
no, they are mutually exclusive
what is compaction
The process of compaction combines all the free memory spaces that are left over from external fragmentation into a big block by reordering the processes. It solves the problem of external fragmentation which is the result of variable memory partitioning.
Which address-binding method do you think a feature like compaction requires?
Compaction requires run time binding as processes are likely to be moved when compaction is done.
how much is 1K
2^10 = 1024
drawback of doing compaction
compaction costs CPU time to perform and because of this it is considered an overhead operation
when and how often should compaction occur
when there are jobs waiting to get in.
after a prescribed amount of time has
elapsed and you suspect your system is in a very fragmented state.