... data up to dev->end */ count = min(count, dev->end - dev->rp); if (copy_to_user(buf, dev->rp, count)) { up (&dev->sem); return -EFAULT; } process and set its state ... (down_interruptible(&dev->sem)) return -ERESTARTSYS; } /* ok, data is there, return something */ if (dev->wp > dev->rp) count = min(count, dev->wp - dev->rp); else /* ... removed from the queue, and the sleep is done. Figure 5- 1 shows the internals of the data structures involved in wait queues and how they are used by processes. Figure 5- 1. Wait queues in Linux...