Things to remember:
int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void * arg);
^ ^ ^ ^
| | | |
| | | |
thread variable we'll always be using NULL thread function arguments for thread function
For example:
void *listenerThread(void *p); pthread_t lt; pthread_create(<,NULL,listenerThread,NULL);
int sem_init(sem_t *sem, int pshared, unsigned int value);
^ ^ ^
| | |
| | |
pointer to seamphore 0 for threads initial value
sem_t foo;
sem_init(&foo,0,0);
int sem_wait(sem_t *sem); sem_wait(&foo);
int sem_post(sem_t *sem); sem_post(&foo);