c - Reader is not reading from a shared memory -


i'm reading file , write on shared memory.but writer writing in shared memory working fine reader not reading shared memory. maxlen[x] have stored maximum length of line.

void * reader (void * param){   int i;   int count=1;   int waittime;    waittime = rand() % 5;   sleep(waittime);      shm_ptr = shmat(shm_id, null, 0);     if ((int)shm_ptr == -1){       printf("*** shmat error (server) ***\n");       exit(1);      }    sleep(1);   printf("\nreader trying enter");   sem_wait(&mutex);   readcount++;    if(readcount==1)      sem_wait(&wrt);    printf("\n%d reader inside ",readcount);   printf(" in crtical section \n");   int sizes=x;   x=0;    while (x<=sizes) {       shm_ptr[x] =  malloc( sizeof(char *)* maxlen[x]);    puts(shm_ptr[x]);    x++;      }    sem_post(&mutex);   sem_wait(&mutex);   readcount--;    if(readcount==0)       sem_post(&wrt);    sem_post(&mutex);   printf("\nreader leaving");   sleep(waittime); }  


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -