#include "sched.h"
#include "pthread.h"
#include "stdio.h"
#include "stdlib.h"
#include "semaphore.h"
#include "string.h"
int producer(void *args);
int consumer(void *args);
pthread_mutex_t mutex ; // a mutex
sem_t product; //semaphore
sem_t warehouse;
char buffer[8][4];
int bp=0;
int main(int argc ,char **argv)
{
pthread_mutex_init(&mutex,NULL);
sem_init(&product,0,0);
sem_init(&warehouse,0,8);
int clone_flag,arg,retval;
char *stack;
clone_flag=CLONE_VM|CLONE_SIGHAND|CLONE_FS|CLONE_FILES;
int i;
for(i=0;i<2;i++)
{
arg=i;
stack=(char *)malloc(4096);
retval=clone((void *)producer,&(stack[4095]),clone_flag,(void *)&arg);