DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Process management

Address space layout

Traditionally, the address space of a SCO OpenServer process has consisted of exactly three segments: one each for write-protected program code (text), a heap of dynamically allocated storage (data), and the process's stack. Text is read-only and shared, while the data and stack segments are private to the process.

System V Release 4 still uses text, data, and stack segments, though these should be thought of as constructs provided by the programming environment rather than by the operating system. As such, it is possible to construct processes that have multiple segments of each ``type,'' or of types of arbitrary semantic value -- no longer are programs restricted to being built only from objects the system was capable of representing directly. For instance, a process's address space may contain multiple text and data segments, some belonging to specific programs and some shared among multiple programs. Text segments from shared libraries, for example, typically appear in the address spaces of many processes. A process's address space is simply a vector of pages, and there is no necessary division between different address-space segments. Process text and data spaces are simply groups of pages mapped in ways appropriate to the function they provide the program.

While the system may have multiple areas that can be considered ``data'' segments, for programming convenience the system maintains operations to operate on an area of storage associated with a process's initial ``heap storage area.'' A process can manipulate this area by calling brk and sbrk:

caddr_t
brk(caddr_t addr);

caddr_t sbrk(int incr);

brk sets the system's idea of the lowest data segment location not used by the caller to addr (rounded up to the next multiple of the system's page size).

sbrk, the alternate function, adds incr bytes to the caller's data space and returns a pointer to the start of the new data area.

A process's address space is usually sparsely populated, with data and text pages intermingled. The precise mechanics of the management of stack space is machine-dependent. By convention, page 0 is not used. Process address spaces are often constructed through dynamic linking when a program is exec'ed. Operations such as exec and dynamic linking build upon the mapping operations described previously. Dynamic linking is described further in Programming in standard C and C++.


Previous topic: Other mapping functions

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005