Write a C program to simulate the following IPC problem Make
Write a C program to simulate the following IPC problem. Make sure to use semaphores to synchronize the processes/threads.
Fraternity Party
A group of fraternity brother and sorority sisters is having a party and drinking from a large communal keg that can hold N servings of soda. When a partier wants to drink, he or she fills a cup from keg, unless it is empty. If the keg is empty, the partier wakes up the pledge and then waits until the pledge has returned with a new keg.
Solution
IPC: Inter process Communication.
Program:
#include<stdio.h>
#include<unistb.h>
#include<stdlib.h>
#include<string.h>
#include<pthread.h>
#include<semaphore.h>
/ the above functions are predefined functions which are required in our program /
void * thread_function(void *arg);
sem_f bin_sem;
#define party_size 1024
/ definition function /
char party_area[party_size];
int main()
{
int result;
pthread_f a_thread;
void *thread_result;
result= sem_init(&bin_sem,0,0);
{
if (result != 0)
{
perror(\" the partier waits for the pledge\");
exit(exit_failure);
}
printf(\" the drink is not filled with keg\");
if(result != 0)
{
perror(\" the partier wake sup the pledge\");
exit(exit_success);
}
printf(\" the drink is filled with the new keg\");
sem_wait (&bin_sem);
}
pthread_exit(null);
}

