🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #49963

Re: gcc and shared data between two processors

#49963
From: Simon Cooper
Date: Wed, 01 Dec 1993 08:09
26 lines
1980 bytes
kims@vnet.ibm.com writes:

>Hello,
>We are developing in a multi-processor environment.  We have shared data
>among the two processors which we could use physically global memory to
>store the data.  On one processor we are trying to use gcc.  Is there any
>way to specify a memory map when compiling this global data?
>
>Thanks in advance for any information you can give.
>Kim Simons  (kims@vnet.ibm.com)

   Use the Ansi C `volatile' keyword to make sure that reads and writes to the
global variables are not optimized out. 
   In addition you will almost certainly need to implement some sort of
`mutual exclusion' primative.  (other names are `mutex', `semaphore',
`spinlocks', etc) You *will* need to `lock' certain pieces of code to
guarantee data consistancy.  If your processor has an indivisible exchange
instruction (where the memory bus is *locked* for two memory cycles whilst the
contents of a memory location is exchanged with a register) you can code it
using the GNU CC `asm' extension and use it as a macro.  Otherwise you'll have
to implement a software locking algorithm (look up semaphores in any reputable
OS design book).  The inline asm feature of GNU CC will allow you to use your
global variables as locks and not incur the penalty of a subroutine call -
this is a very nice feature!

Simon.
Technical Details
Message-ID: <Dec.1.03.09.19.1993.7552@psi.rutgers.edu>
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!dziuxsolim.rutgers.edu!psi.rutgers.edu!scooper
References: <9311302023.AA10083@life.ai.mit.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,d8284d4858877f88
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-12-01 06:57:07 PST
Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!uunet!dziuxsolim.rutgers.edu!psi.rutgers.edu!scooper
From: scooper@psi.rutgers.edu (Simon Cooper)
Newsgroups: gnu.gcc.help
Subject: Re: gcc and shared data between two processors
Message-ID: <Dec.1.03.09.19.1993.7552@psi.rutgers.edu>
Date: 1 Dec 93 08:09:19 GMT
References: <9311302023.AA10083@life.ai.mit.edu>
Distribution: gnu
Organization: Rutgers Univ., New Brunswick, N.J.
Lines: 26