PDA

View Full Version : data at fifo's receiving end has arrived?



quickNitin
11-05-2006, 02:27 AM
How i can come to know that data is available at receiving end of fifo . Is there any way to know this asynchronously other than blocked reading or continuous polling.

situation is such ( presenting in abstract manner): In main thread, an other member-thread is . In this member-thread , i open a fifo for non bloced reading. This fifo will receve values from some other process. And i want to pass these values to main thread.
2 issues are here:
1. How i will come to know some-data is available in fifo. Currently i am going for periodic reading?
2. How to inform this to main thread.

here i know ,a lot of things are fishy. I am looking for guidance how to make that well.

Salem
11-05-2006, 02:34 AM
If the fifo is a file descriptor, then you can use select() or poll() to test whether information is available.

quickNitin
11-05-2006, 03:13 AM
i googled select(). In pages, at some places i found it is blocking for some action o happen over file escriptors. I couldnt get it. I request for elaboration on this.

Also select() provide me partial solution. Here i have to check it whether data is available or not. Is there any other way which kerenel can inform me that something available for reading on this file descriptor and i can do some routuine over that.

Salem
11-05-2006, 03:19 AM
You can specify a timeout with the last parameter to select, to make it wait a while, but ultimately non-blocking.