lubich@bernina.ethz.ch (Hannes Lubich) (01/31/91)
Hi, following figure 2.2 and his remark regarding shmbrk below figure 3.30 in W. Richard Stevens'book "Unix Network Programming" it seems that shared memory segments are "normally" placed between the heap and the stack segment of a process address space. I was asked recently why such segments couldn't be put on the heap just as other dynamically allocated data structures. Besides the argument that heap administration is something totally unrelated to allocation of shared memory segments, ist there any serious problems with placing shared memory on the heap? Are there any advantages, even? Thanks a lot in advance --HaL -- ~ UUCP/Usenet : {known world}!mcsun!cernvax!ethz!lubich ~ or : lubich@ethz.uucp ~ CSNET/ARPA/BITNET : lubich@komsys.tik.ethz.ch ~ The usual disclaimer : No, it wasn't me, somebody must have used my account.
clewis@ferret.ocunix.on.ca (Chris Lewis) (02/04/91)
In article <1991Jan30.174346.28676@bernina.ethz.ch> lubich@komsys.tik.ethz.ch (Hannes Lubich) writes: >Hi, >following figure 2.2 and his remark regarding shmbrk below figure 3.30 >in W. Richard Stevens'book "Unix Network Programming" it seems that >shared memory segments are "normally" placed between the heap and the >stack segment of a process address space. I was asked recently why such >segments couldn't be put on the heap just as other dynamically allocated >data structures. >Besides the argument that heap administration is something totally unrelated >to allocation of shared memory segments, ist there any serious problems with >placing shared memory on the heap? Are there any advantages, even? >Thanks a lot in advance There's a number of difficulties in implementation, as well as some oddness later: - the kernel has no way of telling what linkage structure your program is using to manage heap space - arbitrarily adding a hunk on top would probably end up confusing malloc and friends, certainly because the kernel couldn't update the various linked lists. Worse if you tried to free() one expecially followed by a shared memory detach. - these areas have to be allocated (usually) as pages, and cannot overlap other areas. - worse, these areas may be logically detached from a process. (Yes, I know malloc/free don't necessarily have to have contiguous sbrk's, but putting shared memory into the heap would just tend to confuse things.) There's no real advantage to doing it in the heap. One might suggest the gain of address space, but it would take up the same amount either way because of the page alignment requirements. -- Chris Lewis, Phone: (613) 832-0541, Internet: clewis@ferret.ocunix.on.ca UUCP: uunet!mitel!cunews!latour!ecicrl!clewis Moderator of the Ferret Mailing List (ferret-request@eci386) Psroff enquiries: psroff-request@eci386, current patchlevel is *7*.