How to come a process slept after schedule() call.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I am working on driver locking schemes provided in Linux.
I am doing that with no device just to a handle memory buffer i.e.
just like scull device.

I am not able to get one way of sleeping to work. I am trying out as
said in LLD3.
Please find the code snippets of read/write method implementation of
char driver to demostate a sleep and wakeup:
The write method is:

static DECLARE_WAIT_QUEUE_HEAD(muk_wait);
static DECLARE_WAIT_QUEUE_HEAD(muk_wr_wait);
wait_queue_t my_wait; /* init_wait(&my_wait) in mod init */

ssize_t muk_write(struct file *filp, char const *buff, size_t count,
			loff_t *f_pos)
{
   prepare_to_wait(&muk_wr_wait, &my_wait, TASK_INTERRUPTIBLE);
   schedule();
   finish_wait(&muk_wr_wait, &my_wait);
}

and the read method is as follows:
ssize_t muk_read(struct file *filp, char *buff, size_t count, loff_t *f_pos)
{
   write =FULL;
   wake_up_interruptible(&muk_wr_wait);
   return 0;
}

Whats heppens is:
when I call my write first, it blocks up expected at schedule as it
gives the processor way to CPU.
But when I try to get the control back with a wakeup call from read,
it is not able to wake the slepping Write process up. where am I
missing?

Regards,
Bhanu J

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux