Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site utcsri.UUCP Path: utzoo!utcsri!mason From: mason@utcsri.UUCP (Dave Mason) Newsgroups: net.micro.16k Subject: Need word version of test-and-set Message-ID: <1813@utcsri.UUCP> Date: Tue, 17-Dec-85 18:33:46 EST Article-I.D.: utcsri.1813 Posted: Tue Dec 17 18:33:46 1985 Date-Received: Tue, 17-Dec-85 19:21:23 EST Reply-To: mason@utcsri.UUCP (Dave Mason) Organization: University of Toronto/Ryerson Polytechnic Institute Lines: 44 Keywords: ns32000 compare-and-swap multi-processor Summary: multi-processor synchronization I am looking for a fast way to exit a critical section and see if anyone else was waiting to get in. This is relatively easy (if rather obscure) to do on other processors (like PDP-11, S/370, VAX, MC68000). Despite being a NS32000 booster, I can't think of a way to do this on the NS32000. I would appreciate help particularly from the friendly people at nsc. Here is how I would do it on the PDP-11: flag: .word 1 ; section initially free ; enter critical section decb flag+1 ;say we want in asrb flag ; try & enter bcs wegotit ;do it the slow way...put us in a queue etc. (don't worry about details wegotit: ;critical section ... ;exit critical section add $0x0101,flag ; say it's free & check for anyone waiting bgt weregone ; no-one was...fast exit ;do it the slow way, check the queue etc. (more messy details) (sorry for any non-unix syntax, I've never used unix assemblers) (I did warn you it was obscure...pretty kludgey too...much cleaner & clearer with Compare-and-Swap ala S/370) (Note: the foregoing depends on the read-modify-write cycle for the asrb and the add to be indivisible across processors) (Note: test-and-set won't do the trick (at least not anyway I can see it), because we have to do 2 things: exit the critical section; check for others, in an indivisible way. A 2 bit test & set would do, but compare&swap is the more general solution.) The reason I'm interested in this is that the slow way is 2-3 decimal orders of magnitude slower (for other reasons), and I want this to be a cheap, therefore useful, facility. If the people at National can't come up with something, could I interest you in a nice Compare-and-swap instruction? -- Usenet: {dalcs dciem garfield musocs qucis sask titan trigraph ubc-vision utzoo watmath allegra cornell decvax decwrl ihnp4 uw-beaver} !utcsri!mason Dave Mason, U. Toronto CSRI/ Ryerson Polytech CSNET: mason@Toronto ARPA: mason%Toronto@CSNet-Relay BITNET: FCTY7053@RYERSON.BITNET