home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!jit081.enet.dec.com!diamond
- From: diamond@jit081.enet.dec.com (28-Aug-1992 1129)
- Newsgroups: comp.std.c
- Subject: Re: Implementation of semaphores in "c"
- Message-ID: <9208280233.AA23354@enet-gw.pa.dec.com>
- Date: 28 Aug 92 02:33:55 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Lines: 47
-
- NOTICE TO NEW STUDENTS: Newsgroup comp.std.c is for discussions of
- standardization issues (e.g. ISO/ANSI C standard, maybe POSIX C standard,
- whether various implementations conform, whether various programs are
- strictly conforming, etc.).
-
- In article <1992Aug27.114420.20501@cam.compserv.utas.edu.au> kleung@esk.compserv.utas.edu.au (Kam Leung) writes:
- >#include <stdio.h>
- >#include <sys/types.h>
-
- ISO C doesn't have <sys/types.h>
-
- >#define N 6
- >int s[N], me;
- >enum status {nthinking,vhungry,neating} ;
- >enum status p[N];
- >main()
- >{
- > int i, ;
-
- ISO C doesn't allow an empty declarator (after your comma).
-
- > void PHILOSOPHER(),
- > think(), eat(), hungry();
- > me = 1; /* initial open state of main semaphore */
- > for (i=1;i<N;i++) /*initialise 1-5 philosophers to thinking*/
- > { s[i] = 0; p[i] = nthinking;} /* private semaphore s[i]=0,close*/
- > for (i=1; i<N; i++){
- > if (fork() == 0) PHILOSOPHER(i);
-
- ISO C doesn't have fork().
-
- > }
- > ..
- > ..
- > kill(0,9);
-
- ISO C doesn't have kill().
-
- >}
-
- If the above answers don't help you, then perhaps you need to ask the
- tutors for your course. If they can't help you, then perhaps you need
- to post in a newsgroup concerning the UNIX operating system, to learn
- why separate processes have separate data spaces.
- --
- Norman Diamond diamond@jit081.enet.dec.com
- If this were the company's opinion, I wouldn't be allowed to post it.
-