Path: utzoo!attcan!uunet!samsung!umich!sharkey!indetech!pacbell!sactoh0!unify!csusac!usenet From: brian@babbage.csus.edu (Brian Witt) Newsgroups: comp.sys.amiga.tech Subject: Re: Semaphores (Why don't we use 'em?) Summary: SimCity uses Signal Semaphores! Message-ID: <1990Jul1.214920.14333@csusac.csus.edu> Date: 1 Jul 90 21:49:20 GMT References: <709.268c893f@desire.wright.edu> Organization: California State University, Sacramento Lines: 34 In article <709.268c893f@desire.wright.edu> arc@desire.wright.edu writes: > There >are only 2 programs that I've seen that use there own semaphore and these >are Tracksalve and some other program (I forget it;s's name). How come >more people don't use semaphrores? Wouldn't they help out a lot in some >areas? I know that semaphorses in a Vax is useful for synchronizing tasks... >Is this what they are used for on the Amiga? Would someone PLEASE elaborate? OK, SimCity on the Amiga uses semaphores. When the Maps and Graphs screen needs updating it lokks the simulators database, redraws the map, then unlocks (V operation). Great way to provide consistant results!! :-) The application is user-time (ie, slow realtime), so someone can wait if they need to without damaging results. The critical section was entered only ocassionally (about once every 15 seconds). The lesson from the experience is: make the "locking mechanism" as "light" as possible. Perhaps code like: while(in_use) Delya(50L); would work just as well (ignoring race conditions). Kids, don't do this at home. (Please don't flame this paragraph. OK?) Since the code was developed simutaneously for the Amiga and the Macintosh, it was hard to get Amiga specific code in the simulator that ran in the background. In this case, it was more a problem of code clutter than actual programmer ignorance. BTW, to however wrote the Signal Semaphore package (I think Neil Katin): very cute, very sneaky, very clever solution; I like it! :-) :-) :-) > /Bryan --- Laws seldom stop polititicans --- brian witt uunet.uu.net!seer.UUCP!rael!aleks