//#include #include "semaphore.h" //#include //#include #define pthread_attr_default NULL #define pthread_mutexattr_default NULL #define pthread_condattr_default NULL //using namespace std; void* writer(void *ptr); Semaphore writeWait; Semaphore endWait; int main () { pthread_t thread1, thread2; //semaphore_init (&writeWait,0); semaphore_init (&endWait,-1); char * hello = "hello"; char * world = ", world!\n"; pthread_create( &thread1, pthread_attr_default, (void *)&writer, (void *)hello); pthread_create( &thread2, pthread_attr_default, (void *)&writer, (void *)world); semaphore_down(&endWait); return 0; } void* writer(void *ptr) { char * out; out = (char*)ptr; printf("%s",out); fflush(stdout); semaphore_up(&endWait); }