Path: utzoo!attcan!uunet!husc6!bloom-beacon!gatech!uflorida!umd5!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: volatile, shared memory, and synchronisation Message-ID: <11629@mimsy.UUCP> Date: 23 May 88 20:04:04 GMT References: <20345@pyramid.pyramid.com> <833@mcdsun.UUCP> <9916@tekecs.TEK.COM> <199@gannet.cl.cam.ac.uk> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 25 In article <199@gannet.cl.cam.ac.uk> scc@cl.cam.ac.uk (Stephen Crawley) writes: >... multi-process applications that use shared memory. Consider two >processes A and B with a shared variable v, and the following code > int x = v /* A1 */ | v = 2 /* B1 */ > int y = v /* A2 */ | Even *with* volatile declarations, you get no solid guarantee. Suppose that v is a `volatile int', and that you are running on a bit-oriented binary machine and v has been placed across two different memory banks. The sequence might be A1, B1 , A2, B1 : A1: x = 1 | v = 0...0 1 B1: v = 2 | v = 0...0 0 A2: y = 0 | v = 0...0 0 | v = 0...1 0 This is perhaps unlikely, but in fact something similar could easily happen on a multi-cpu R2000-based system (assuming 32 bit integers), although not with the values 1 and 2. Volatility is only part of what you need for synchronisation. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris