2022-10-03 03:50:44 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
typedef struct sem_t
|
|
|
|
{
|
|
|
|
;
|
|
|
|
} sem_t;
|
|
|
|
|
|
|
|
void* ThreadOne(void* voidPass);
|
|
|
|
void* ThreadTwo(void* voidPass);
|
|
|
|
void sem_post(sem_t* semaphore);
|
|
|
|
void sem_wait(sem_t* semaphore);
|
|
|
|
|
|
|
|
sem_t aArrived, bArrived;
|
|
|
|
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Thread A for testing multithread
|
|
|
|
void* ThreadOne(void* voidPass)
|
|
|
|
{
|
|
|
|
printf("a1\n");
|
|
|
|
sem_post(&aArrived);
|
|
|
|
sem_wait(&bArrived);
|
|
|
|
printf("a2\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Thread B for testing multithread
|
|
|
|
void* ThreadTwo(void* voidPass)
|
|
|
|
{
|
|
|
|
printf("b1\n");
|
|
|
|
sem_post(&bArrived);
|
|
|
|
sem_wait(&aArrived);
|
|
|
|
printf("b2\n");
|
|
|
|
}
|