home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / amiga / programm / 11555 < prev    next >
Encoding:
Text File  |  1992-07-23  |  1.8 KB  |  49 lines

  1. Newsgroups: amiga.prog,comp.sys.amiga.programmer
  2. Path: sparky!uunet!stanford.edu!ames!elroy.jpl.nasa.gov!jato!jdickson
  3. From: jdickson@jato.jpl.nasa.gov (Jeff Dickson)
  4. Subject: Re: Signal Semaphores
  5. Message-ID: <1992Jul23.155641.7933@jato.jpl.nasa.gov>
  6. Organization: Jet Propulsion Laboratory
  7. References: <rwm.711692783@atronx.OCUnix.On.Ca>
  8. Date: Thu, 23 Jul 1992 15:56:41 GMT
  9. Lines: 38
  10.  
  11. In article <rwm.711692783@atronx.OCUnix.On.Ca> rwm@atronx.OCUnix.On.Ca (Russell McOrmond) writes:
  12. >
  13. >  I'm wondering if anyone has done extensive work with SignalSemaphores under
  14. >2.04 (V37) that could let me know what I'm doing wrong with my use of them.
  15. >I just put a 'Forbid()/Permit()' pair around all the things
  16. >that 'should' have been protected by an ObtainSemaphore/ReleaseSemaphore
  17. >pair in some multi-threaded code, and a large number of bugs just 'went away'.   
  18. >Since I'd rather that ALL tasks didn't wait, and only those wanting access 
  19. >to these structures, I'd rather get things working.
  20. >
  21. >  The program in question runs many different processes, all of which share
  22. >the same global variables.  When accessing any of the structures, I had put
  23. >semaphore arbitration around the calls. Here's some 'example' code from what
  24. >I'm doing:
  25.  
  26. I've done extensive work with the signal semaphore stuff, but from Assembly.
  27. You didn't say what C compiler you're using. If an older MANX (i.e. <= 3.6)
  28. then the statement:
  29.  
  30. >  if((myconfig=AllocMem(sizeof(config),MEMF_CLEAR))) {
  31.  
  32. would be wrong if sizeof(config) returns a 16 bit integer instead of a 32 bit
  33. which AllocMem expects.
  34.  
  35. >
  36. >typedef struct config_struct {
  37. >  struct slave_struct mainSlave;
  38. >  /* Slaves */
  39. >  struct SignalSemaphore listLock;
  40. >
  41.  
  42. And what are you doing here? Redefining what the keyword struct means?
  43.  
  44. Investigate those items. Next time post how you declare "config".
  45.  
  46. jeff
  47.  
  48.  
  49.