hall@uunet.UU.NET (Craig Hall) (09/10/90)
I am sure this is a really simple problem but I can't find what I am doing wrong. I am using the 3L Parallel C for the first time, and am having difficulty getting threads and par_printf to do what I expect. The following is some code to see what they do, .... BUT it doesn't. When I run this program I get both of the printfs from main with i=0 which I kind of expected, but nothing from the threads and the never program terminates. Are there any of you who have used these constructs before and would be willing to point out what is amiss?? #include <thread.h> #include <sema.h> #include <par.h> SEMA i_free; int i; main(argc, argv) int argc; char *argv[]; { extern void add(); int j; sema_init(&i_free,1); i = 0; par_printf("before threads i is %d\n",i); for(j=0; j<5; j++) thread_create(add,256,1,j); /* just a big guess on the wssize */ par_printf("after threads i is %d\n",i); } void add(k) int k; { sema_wait(&i_free); i++; sema_signal(&i_free); par_printf("in thread %d, i is %d\n",k,i); } P.S. Are there any good books on the market that cover parallel C programming conventions? Thanks in advance: Craig Hall Bewildered student. ...uunet!isc-br!ewu!hall hall%ewu@uunet.uu.net