C191-Terms-Chapter-7 Flashcards
physical memory (RAM)
is a hardware structure consisting of a linear sequence of words that hold a program during execution.
word
A word is a fixed-size unit of data. A typical word size is 1, 2, or 4 bytes.
physical address
an integer in the range [0: n-1] that identifies a word in a physical memory of size n. The address comprises a fixed number of bits. A memory of size n requires an address size of k bits, where n = 2^k.
During program development, the starting address of a program in physical memory is unknown.
To facilitate program development and the sharing of physical memory, the concept of a logical address space is employed.
logical address space
an abstraction of physical memory, consisting of a sequence of imaginary memory locations in a range [0: m-1], where m is the size of the logical address space.
logical address
an integer in the range [0 : m-1] that identifies a word in a logical address space. Prior to execution, a logical address space is mapped to a portion of physical memory and the program is copied into the corresponding locations.
source module
a program or a program component written in a symbolic language, like C, or an assembly language, that must be translated by a compiler or assembler into executable machine code.
object module
the machine-language output of a compiler or assembler generated from a source module. An object module may be self-contained and executable or multiple object modules may be linked together into a load module by a linker or linkage editor.
load module
a program or combination of programs in a form ready to be loaded into main memory and executed.
Relocation and address binding
The physical addresses of the program components aren’t known until load time, the compiler/assembler and the linker assume logical address spaces starting with address 0.
During each step of the program transformation, the logical addresses of instructions and data may be changing. Only during the final step of program loading are all logical addresses bound to actual physical addresses in memory.
relocation
Program relocation is the act of moving a program component from one address space to another. The relocation may be between two logical address spaces or from a logical address space to a physical address space.
Static relocation
binds all logical addresses to physical addresses prior to execution.
Dynamic relocation
postpones the binding of a logical address to a physical address until the addressed item is accessed during execution.
relocation register
contains the physical starting address of a program or program component in memory.
Most programs consist of 3 main components: code, static data, and dynamic data. A simple memory management scheme treats the 3 components as one unit, which must be moved into one contiguous area of memory.
Dynamic relocation
can be implemented using a single relocation register, which is loaded with the program’s starting address.
The register content is then added automatically by the CPU to every logical address of the program to generate the physical address.
A more flexible management scheme treats the 3 components as separate modules, each of which may reside in a different area of memory.
Three relocation registers, each loaded with the starting address of one of the modules, then accomplish dynamic relocation by being added to all logical addresses at runtime.
Free space management
As programs are moved into and out of memory at runtime, the memory space becomes a checkerboard of free and occupied areas of different sizes.
The OS keeps track of all free spaces, referred to as holes, using a linked list and must find a hole of appropriate size whenever a new program component is to be loaded into memory.
The OS must also coalesce any neighboring holes resulting from the removal of programs from memory to prevent the memory from becoming a fragmented collection of increasingly smaller holes.
Different search strategies have been explored, they include first-fit, next-fit, best-fit, and worst-fit.
First-fit
always starts the search from the beginning of the list and allocates the first hole large enough to accommodate the request.
Next-fit
starts each search at the point of the last allocation.
Best-fit
searches the entire list and chooses the smallest hole large enough to accommodate the request.
Worst-fit
takes the opposite approach from best-fit by always choosing the largest available hole for any request.
Simulation of different strategies have not produced a clear winner. The choice depends on the average request size relative to the memory size, and the variance of request sizes.
relocatable object file
The output of a compiler in which the contents can be loaded into any location in physical memory.