views:

26

answers:

1

hi there i write readers and writers where the kernel have to syncronize between them and block writer who already read a massage

when i am in the queue waiting I get signal so I do the fallowing

while (i_Allready_Read(myf) == ALLREADY_READ || isExistWriter == false )
//while (!(i_Allready_Read(aliveProc,current->pid)))
{
    int i, is_sig = 0;
    printk(KERN_INFO "\n\n*****entered set in read ******\n\n" );
    if (i_Allready_Read(myf) == ALLREADY_READ )
        wait_event_interruptible (readWaitQ1, !i_Allready_Read(myf));
    else
        wait_event_interruptible (readWaitQ1, isExistWriter);

    //printk(KERN_INFO "Read Wakeup %d\n",current->pid);

    for (i = 0; i < _NSIG_WORDS && !is_sig; i++)
    {
        is_sig = current->pending.signal.sig[i] & ~current->blocked.sig[i];
    }

    if (is_sig)
    {
        handledClose(myf);
        module_put (THIS_MODULE);
        return -EINTR;
     }
   }
   return 0;//success

}

inline void handledClose(struct file *myf)//v

{ /* *if we close the writer other writer *would be able to enter to permissiones */

if (myf == writerpid )
{
    isExistWriter = DOESNT_EXIST;
    //printk(KERN_INFO "procfs_close : this is pid that just closed %d \n", writerpid);
}
/*
 *else its a reader so our numofreaders
 *need to decremented
*/
else
{
    removeFromArr(myf);
    numOfReaders--;
}

}

and my close does nothing ...

what did i do wrong?

+1  A: 

Where are you waking up the wait queue?

You should be calling wake_up(readWaitQ1); somewhere. Possible after you set isExistWriter to true.

caf