I have 2 submit a code for sleeping barber problem in college. I am getting a few errors using semaphores in this program.

The program is:

#define _REENTRANT
#include<stdio.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<stdlib.h>
#include<pthread.h>
#include<semaphore.h>
#define MAX 25

void *customer(void *num);
void *barber(void *);
void randomwait(int secs);
sem_t wwait;
sem_t chair;
sem_t pillow;
sem_t belt;
int done=0;

int main(int argc,char *argv)
{
pthread_t btid;
pthread_t tid[MAX];
long rand;
int i,n,ch,l;
int a[25];

if(argc!=3)
{
printf("Use:sleep barber <num of cust> <num chairs> <rand seed>\n");
exit(-1);
}
n=atoi(argv[1]);
ch=atoi(argv[2]);
rand=atol(argv[3]);

if(n>MAX)
{
printf("Maximum number of customers is %d\n",MAX);
exit(-1);
}
n=atoi(argv[1]);
ch=atoi(argv[2]);
rand=atol(argv[3]);

if(n>MAX)
{
printf("Maximum number of customers is %d\n",MAX);
exit(-1);
}
printf("Solution to sleeping barber problems using semaphore\n");
srand48(rand);
for(i=0;i<MAX;i++)
{
a[i]=i;
}
sem_init(&wwait,0,ch);
sem_init(&chair,0,1);
sem_init(&pillow,0,0);
sem_init(&belt,0,0);
pthread_create(&btid,NULL,barber,NULL);
for(i=0;i<MAX;i++)
{
pthread_create(&tid[i],NULL,customer,(void *)&a[i]);
}
for(i=0;i<MAX;i++)
{
pthread_join(tid[i],NULL);
}
done=1;
sem_post(&pillow);
pthread_join(btid,NULL);
}
void randwait(int secs)
{
int len;
len=(int)((drand48()*secs)+1);
sleep(len);
}

The warnings which I got are:

sleepy.c: In function ‘main’:
sleepy.c:33: warning: passing argument 1 of ‘atoi’ makes pointer from integer without a cast
sleepy.c:34: warning: passing argument 1 of ‘atoi’ makes pointer from integer without a cast
sleepy.c:35: warning: passing argument 1 of ‘atol’ makes pointer from integer without a cast

Even though i thought, warnings could be avoided, the program does not work at all.
Also, i am new to semaphores as i have not coded any program with semaphores or pthreads earlier and i am unable to locate and debug the error
I found this algorithm in a textbook of mine.


I would be greateful if somebody helped me, as this carries 50 marks.

thank you