Linux poll and select

Source: Internet
Author: User
The character device driver in Linux has a function
Unsigned int (* poll) (struct file * FP, struct poll_table_struct * table)
This function is used within the system call select to hook the current file pointer to the wait defined inside the device.
Queue. The parameter table here can be ignored. It is an internal variable during the implementation of the select function.

Function implementation:
Wait_queue_head_t = (struct mydev *) filp-> private_data)-> wait_queue;

Poll_wait (filp, T, table );

Return mask;

Here mask can be:
Pollin | pollrdnorm
Pollout | pollwrnorm
And so on.

The role of poll_wait is:
Apply for an entry in the table, and each entry has a wait_queue_t. Then, Mount wait_queue_t to the queue of T, and then mount filp to the entry.
Here, filp is defined in the fdset of the select function.

Then in the driverProgramInternal, if data enters, it is called in the program
Wake_up_interruptible (& mydev-> wait_queue );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.