views:

257

answers:

3

Note: I'm attempting to study a high-level overview of Virtual Memory allocation

Is an entire process's virtual address space split into pages, of a particular size:

  .text
  .bss
  .data

Does this also include heap space and stack - or is this always non-pageable?

+1  A: 

.data is where the program's initialized global variables lay. .bss contains the globals without an explicit initializer (with a default value of 0). The heap and stack are separate memory zones from these and from each other. All the memory seen by a process is all virtual memory split in pages. A process doesn't see anything else than virtual memory.

Pascal Cuoq
+2  A: 

Typically, on a paged operating system a processes entire address space is split into pages. Each linear address contains two components - a page number in the most significant bits, and an offset within the page in the least significant bits.

For example, with 32 bit linear addresses and 4kB pages, the upper 20 bits are a page number and the lower 12 bits are a page offset.

caf
+2  A: 

First note that "pages" are simply regions of an address space. A region that is "non-pageable" (by which I assume you mean it cannot be swapped to disk) is still logically divided into pages, but the OS might implement a different policy on those pages.

The most common page size is 4096 bytes. Many architectures support use of multiple page sizes at the same time (e.g. 4K pages as well as 1MB pages). However, operating systems often stick with just one page size, since under most circumstances, the costs of managing multiple page sizes are much higher than the benefits this provides. Exceptions exist but I don't think you need worry about them.

Every virtual page has certain permissions attached to it, like whether it's readable, writeable, executable (varies depending on hardware support). The OS can use this to help enforce security, cache coherency (for shared memory), and swapping pages out of physical memory.

The .text, .bss and .data regions need not be known to the OS (though most OSes do know about them, for security and performance reasons).

The OS may not actually allocate memory for a stack/heap page until the first time that page is accessed. The OS may provide system calls to request more pages of heap/stack space. Some OSes provide shared memory or shared library functionality which leads to more regions appearing in the address space. Depends on the OS.

Artelius