home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / std / c / 2530 < prev    next >
Encoding:
Text File  |  1992-08-27  |  1.8 KB  |  57 lines

  1. Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
  2. From: diamond@jit081.enet.dec.com (28-Aug-1992 1129)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Implementation of semaphores in "c"
  5. Message-ID: <9208280233.AA23354@enet-gw.pa.dec.com>
  6. Date: 28 Aug 92 02:33:55 GMT
  7. Sender: daemon@ucbvax.BERKELEY.EDU
  8. Lines: 47
  9.  
  10. NOTICE TO NEW STUDENTS:  Newsgroup comp.std.c is for discussions of
  11. standardization issues (e.g. ISO/ANSI C standard, maybe POSIX C standard,
  12. whether various implementations conform, whether various programs are
  13. strictly conforming, etc.).
  14.  
  15. In article <1992Aug27.114420.20501@cam.compserv.utas.edu.au> kleung@esk.compserv.utas.edu.au (Kam  Leung) writes:
  16. >#include <stdio.h>
  17. >#include <sys/types.h>
  18.  
  19. ISO C doesn't have <sys/types.h>
  20.  
  21. >#define N              6
  22. >int  s[N], me;
  23. >enum status {nthinking,vhungry,neating} ;
  24. >enum status p[N];
  25. >main()
  26. >{
  27. >  int i, ;
  28.  
  29. ISO C doesn't allow an empty declarator (after your comma).
  30.  
  31. >  void  PHILOSOPHER(),
  32. >        think(), eat(), hungry();
  33. >  me = 1;    /* initial open state of main semaphore */
  34. >  for (i=1;i<N;i++) /*initialise 1-5 philosophers to thinking*/
  35. >      { s[i] = 0; p[i] = nthinking;}  /* private semaphore s[i]=0,close*/
  36. >  for (i=1; i<N; i++){
  37. >       if (fork() == 0) PHILOSOPHER(i);
  38.  
  39. ISO C doesn't have fork().
  40.  
  41. >  }
  42. >        ..
  43. >        ..
  44. >  kill(0,9);
  45.  
  46. ISO C doesn't have kill().
  47.  
  48. >}
  49.  
  50. If the above answers don't help you, then perhaps you need to ask the
  51. tutors for your course.  If they can't help you, then perhaps you need
  52. to post in a newsgroup concerning the UNIX operating system, to learn
  53. why separate processes have separate data spaces.
  54. --
  55. Norman Diamond       diamond@jit081.enet.dec.com
  56. If this were the company's opinion, I wouldn't be allowed to post it.
  57.