schedule()

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

 






Hi,

  This is the way I intend to block the read call on my char device, if
there is no data to be read.

      void block() {
            DECLARE_WAITQUEUE(w, current);
            __add_wait_queue(&some_wait_queue, &w);
            current->state=TASK_INTERRUPTIBLE;
            if (!isready())
                  schedule();
            current->state=TASK_RUNNING;
            remove_wait_queue(&some_wait_queue, &w);
      }

Is this fine OR should I check after schedule() returns that there is now
something to read by calling isready() again. Isread() checks my input
queue to find, if there is something in the queue.

i.e should it be something like this :
      while (!isready())
            schedule();
      current->state=TASK_RUNNING;
      remove_wait_queue(&some_wait_queue, &w);

or, the previous one wld work just fine ?

thanks
Amit

"DISCLAIMER: This message is proprietary to Hughes Software Systems Limited
(HSS) and is intended solely for the use of the individual to whom it is
addressed. It may contain  privileged or confidential information and
should not be circulated or used for any purpose other than for what it is
intended. If you have received this message in error, please notify the
originator immediately. If you are not the intended recipient, you are
notified that you are strictly prohibited from using, copying, altering, or
disclosing the contents of this message. HSS accepts no responsibility for
loss or damage arising from the use of the information transmitted by this
email including damage from virus."


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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