2. Memory management is
mainly related to allocation of
main memory for requests of
processes. There are two
important features of the
Memory Management
Function: Security and
Sharing. Memory
management activity in the
Linux kernel There are some
key issues related to memory
management :
Architecture - independent memory model in Linux
3. Pages of Memory :
Physical memory is divided into pages. The size of the memory page is defined by the PAGE_SIZE
macro. For x86 processors, the size is set to 4 KB, while the Alpha processor uses 8 KB.
Virtual address space :
A process runs in the virtual address space. In the abstract memory model, virtual address space is
structured as kernel segment and user segment. The code and data for the kernel can be accessed in
kernel segments, and the code and data for the process in the user segment.
A virtual address is given in the context of the offset within the Segment selector and Segment.
When the code is being processed, the Segment selector has already been set and only the offset is
used. In the kernel, to pass the parameter, data in the kernel segment requires data not only in the
user segment. For this purpose, the put_user () and get_user () functions are defined.
The programmer simply refers to the memory address as the way to access the contents of the
memory unit. In the x86 Micro processor, we have three addresses.
4.
5. (i) Logical Addresses :
Contained in machine language instructions that specify the address of an operand or instruction.
Each logical address has a segment and offset that represents the distance from the beginning of the
segment to the real address.
(ii) Linear Address :
A single 32-bit unsigned integer that can be used to process up to 4 GB of data and up to 232
locations.Linear addresses are usually shown in hexadecimal notation; Their values are 0x00000000
to 0xffffffff.
(iii) Physical Address :
The physical address is used to address the memory cells included in the memory chip.
They match electrical signals that are sent to the subject bus with the address pin of the
microprocessor.The physical address is represented as a 32-bit unsigned integer.
6. Converting the Linear address :
Linux uses a three-level paging model, so paging on a 64-bit architecture is feasible. The x86 processor only supports
two-level conversion of linear addresses.Alpha processor supports three-level conversion because Alpha processor
supports linear addresses with a width of 64 bits
Three level paging model defines three types of paging table :
Page (Global) directory
Page middle directory
Page Table
Page Global Directory :
The page global directory includes the addresses of the intermediate directories of multiple pages. It is 12 bits long.
The different functions that can be used to modify the Page Global directory are:
(i) pgd_alloc () : Allocates a Page Directory and filles with 0.
(ii) pgd_bad() :It can be used to check if entry in the page directory is valid or not.
(iii) pgd_clear() : Delete the entry in page directory.
(iv) pgd_free() :Advertise the page of allocated memory in the page directory.
(v) pgd_none() : Tests whether the entry has been initialized.
Page Middle Directory :
7. This includes the address of several page tables. It's 13 bit length. Actions used to handle page middle directory:
(i) pmd_alloc() : Allocates a Page Middle directory to manage memory in
user area.
(ii) pmd_bad() :Test whether the entry in the page mid directory is valid.
(iii) pmd_clear() :The page removes entries in central entries is valid.
(iv) pmd_free() :A page central directory for memory in the user section releases. (v) pmd_offset (): The page
gives an entry address in the central directory
Which is the address allotted in the logic.
(vi) pmd_none() : Tests whether the entry in the page middle directory has been
set.
Page Table :
Each page table entry points to a page frame. It is 25 bits long. When modifying the contents of the memory
page, set the 'dirty' attribute. The page table entry contains a number of flags that describe the legal access
mode of the memory page and its status:
PAGE_NONE : No physical memory page is referenced by page table entry.
PAGE_SHARE : All types of Access are permitted.
8. PAGE_COPY : This macro is historical & identical toPAGE_READONLY.
PAGE_READONLY: Only read and execute access is allowed to this Page of
memory.
PAGE_KERNEL : Access to this page of memory is only allowed in the kernel
segment.
Following are some functions have been defined to manipulate the page table entries and their attributes :
(i) mk_pte() : pgprot_t type is a variable when Returned on a page table entry that is generated from the memory address
of a page
(ii) pte_alloc() : Allocates new page table.
(iii) pte_clear() : clears the page table entry.
(iv) pte_dirty() : it checks for ‘dirty’ attributes after it is set
(v) pte_free() : Releases the page table.
Call us @ 9988741983
Website: http://cbitss.in