Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is memory management in the Linux Kernel done using paging or segmentation or both?

share|improve this question

migrated from stackoverflow.com Mar 12 '11 at 23:14

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers 2

Linux uses both. It uses segmentation to map all the available address space while giving different access rights: basically a kernel and a user space view. You can grep the Linux source code for KERNEL_DS (kernel data segment) for some examples.

Paging is then used for implementing virtual memory (Grep for "struct gdt_page" in the kernel, for a starting point)

share|improve this answer
add comment

Memory management under Linux works exclusively by paging.

Linux supports both "small" (usually 4kB) and "large" (2M) pages. The former "just work" without you knowing or doing anything special, and the latter need special treatment (have to be reserved at boot time and mapped via a special device).

The only context in which "segment" appears under Linux is the brk() syscall which is used to increase the data segment of a process (you will not normally need this, malloc does it without you having to care). But either way, the memory comes in pages and is managed in pages, and it has nothing to do with x86 segmentation.

share|improve this answer
    
X86 segmentation was obsolete when the i386 came out. Linux has never used segmentation for memory management. Some derivatives like ELKS and (possibly) uClinux might. –  ultrasawblade Mar 12 '11 at 23:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.