sbrk() and brk() semantics
Michel Tombroff
tom at opera.chorus.fr
Sun Dec 16 00:21:54 AEST 1990
Here is a question related to the "semantics" of the brk()/sbrk()
UNIX system calls. If this has already been discussed on the NewsNet,
can somebody just send me pointers. Thanks.
sbrk(incr) : incr more bytes are added to the program's data
and a pointer to the start of the new area is returned.
In all the implementation of sbrk() I have seen, the data area
of a process is a region that grows towards increasing virtual addresses.
This means that successive calls to sbrk() with positive increments
will return increasing addresses.
My questions are the following:
1/ is this feature part of the "semantics" of the sbrk() system
call, or is it a property of most actual UNIX implementations
to have bss segments growing upward?
2/ would it make sense to implement a bss into a region growing towards
lower addresses. Suppose for instance my bss is a region whose
most positive virtual address is fixed, and trying to extend its
size would make it extend towards a smaller address:
before after sbrk(SIZE);
_____________ _____________
| | | | <-- high virtual addr
| | | |
| | | |
| | | |
| BSS | | BSS |
| | | |
| | | |
| | | |
| | | |
------------- | |
| |
| |
| |
SIZE bytes | |
added | |
| |
| |
------------- <-- low virtual addr
Note: we suppose here that there are no problems of overlapping, ...
with the text/stack regions.
3/ in the case this makes sense, what is the amount of UNIX
code ( I mean commands, programs, utilities, X servers ) that would
have to be rewritten. In other words, how much of UNIX programs
make the assumption of "growing upward" memory regions.
Thanks,
-tom
________________________________________________________________________
Michel Tombroff Tel: +33 (1) 30 64 82 77
Chorus Systemes Fax: +33 (1) 30 57 00 66
6 Av. Gustave Eiffel Email: tom at chorus.fr
78182 Saint-Quentin-En-Yvelines
France
More information about the Comp.unix.questions
mailing list