HELP! * GREY=local LOCAL HTML version of Foils prepared July 6,1995

Foil 34 TCE -- Implementation -- 12: Synchronization Example

From Master Foils for Threads with TCE in detail CPS600 Spring Semester95 -- April 1995. by Janusz Niemiec and Geoffrey Fox * Important Information in IMAGE

TCE_Sem *sem,*wait;
...
void func1(p1)
{
  • ...
  • tce_sem_down(sem); /* enter critical section */
  • ... /* do some work */
  • tce_sem_up(sem); /* leave critical section */
  • tce_sem_down(wait); /* wait for parent to let me exit */
}
void func2(p2)
{ ...
  • tce_sem_down(sem);
  • ... /* do some work */
  • tce_sem_up(sem);
  • tce_sem_down(wait);
}
void main(int argc, char *argv[])
{
  • TCE_Thrd *thrd1,*thrd2;
  • int prm1,prm2;
  • ...
  • wait = tce_sem_init(0); /* create semaphore, set counter to 0 */
  • sem = tce_sem_init(1);
  • thrd1 = tce_thrd_init(func1,prm1);
  • tce_thrd_start(thrd1);
  • thrd2 = tce_thrd_init(func2,prm2);
  • tce_thrd_start(thrd2);
  • ...
  • tce_sem_free(); /* let them proceed */
  • ...
}



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Tue Feb 18 1997