Page 271 - DCAP403_Operating System
P. 271
Operating System
Notes For example, in Figure 13.5, if page frame number 1 were to be freed, then that would be combined
with the already free page frame number 0 and queued onto element 1 of the free_area as a free
block of size 2 pages.
13.5.9 Memory Mapping
When an image is executed, the contents of the executable image must be brought into the
processes virtual address space. The same is also true of any shared libraries that the executable
image has been linked to use. The executable file is not actually brought into physical memory,
instead it is merely linked into the processes virtual memory. Then, as the parts of the program
are referenced by the running application, the image is brought into memory from the executable
image. This linking of an image into a processes virtual address space is known as memory
mapping.
Every processes virtual memory is represented by an mm_struct data structure. This contains
information about the image that it is currently executing (for example bash) and also has pointers
to a number of vm_area_struct data structures. Each vm_area_struct data structure describes the
start and end of the area of virtual memory, the processes access rights to that memory and a set
of operations for that memory. These operations are a set of routines that Linux must use when
manipulating this area of virtual memory. For example, one of the virtual memory operations
performs the correct actions when the process has attempted to access this virtual memory but
finds (via a page fault) that the memory is not actually in physical memory. This operation is
the nopage operation. The nopage operation is used when Linux demand pages the pages of an
executable image into memory.
Figure 13.6: Areas of Virtual Memory
Processes Virtual Memory
Virtual Area
vm_area_struct
vm_end
vm_start
vm_flags
vm_i node
Virtua Memory
vm_ops
Operations
open ()
vm_next
close ()
nomap ()
protect ()
sync ()
adivse ()
nopage ()
wppage ()
swapout ()
swapin ()
264 LOVELY PROFESSIONAL UNIVERSITY