Hi, Can anyone tell me the use of poll or select system call.
Why we call poll_wait() function in poll or select system call for each of our
wait queues maintained by our driver (refer to Rubini’s chapter 5). What exactly is the use of poll_wait() function. I dig out the kernel sources for poll_wait function (which is
a macro), it further calls __pollwait() function defined in select.c Implementation of __pollwait() function can been seen at
following link http://lxr.linux.no/source/fs/select.c?v=2.4.21#L75 As you can see at above link, __pollwait() function uses the
poll_table, poll_table_page and poll_table_entry data structures. Finally these structures are binding the wait queues passed
as second argument in poll_wait() call with the poll_table (passed as a second
argument in poll system call). It means we are passing the pointers to the wait queues
maintained by our device driver to the user process by poll_table , which the
user process has passed thru system call. Is it not something dangerous, as we
are exposing the kernel data structures (wait queues maintained by our driver)
to the user process. Wait queues further contain pointers to the task_struct
structures representing process sleeping on that wait queue, so we are exposing
a lot of kernel pointers and data structures to user process by means of
poll_table pointer passed by user process as an argument to poll system call. If I am wrong at some place, please correct me, other wise
please help me to analyze the poll and select system calls in better way. Finally I am also not able to understand the core purpose of
providing wait queue details to user space thru poll or select system call. Regards, Gaurav |