Re: Adding "shared" to C, need sysv386 .section syntax

pja@ralph.lafayette.la.us (Pete Alleman)
Wed, 25 Sep 1991 00:55:06 GMT

          From comp.compilers

Related articles
Adding "shared" to C, need sysv386 .section syntax steve@nuchat.sccsi.com (1991-09-19)
Re: Adding "shared" to C, need sysv386 .section syntax pja@ralph.lafayette.la.us (1991-09-23)
Re: Adding "shared" to C, need sysv386 .section syntax steve@nuchat.sccsi.com (1991-09-24)
Re: Adding "shared" to C, need sysv386 .section syntax pja@ralph.lafayette.la.us (1991-09-25)
| List of all articles for this month |
Newsgroups: comp.compilers,comp.unix.sysv386
From: pja@ralph.lafayette.la.us (Pete Alleman)
Keywords: C, 386, assembler
Organization: Home Sweet Home, Lafayette, LA
References: 91-09-052 91-09-059
Date: Wed, 25 Sep 1991 00:55:06 GMT

>[Are any of these hacks appreciably faster than putting all the shared
>stuff in a big structure, keeping a pointer to the structure that is set
>from the result of shmat(), and maybe using preprocessor defines to make
>it look prettier? -John]


The speed difference is small enough that it is not much of a factor.
Some advantages of using the linker to resolve the addresses:


* One of my applications involves 18 processors, each with some memory,
communicating and sharing data across all the memories. The
shared data must be split across the 18 data spaces. It
is not easy to have to worry about those addresses at
source level. (This is probably a rather unusual example
of Unix shared memory.)


* Resolving addresses is the linker's job.


* Data hiding. If I have a routine which needs some small data
structure from the shared data segment, I would hate to
have to include the definitions of all the data
structures in shared data just to get my little
structure. Also, with your suggestion, every subroutine
which references shared data must be recompiled if
anything is changed in the shared data structure. This
can be a configuration control problem.


The main disadvantage of using the linker:


* Link control files tend to be rather non-portable.


* The syntax of the link control file tends to be rather poorly
documented.


When writing small applications I used your approach. When
the application grew and problems arose I solved them with the
linker. As always, use the simplest approach which solves the
problem satisfactorily.
--
Pete Alleman
pja@ralph.lafayette.la.us
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.