- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How can i implement something like poll()
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2001 06:48 PM
09-05-2001 06:48 PM
But polling the queue is wasting CPU time if the queue is empty. I want to implement something like poll() on the data queue. If the queue is empty and there is nothing to do, reading thread registers a readable event on it and block. After the data queue is writed and is no more empty, reading thread is waked up.
Is this idea naive ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2001 10:12 PM
09-05-2001 10:12 PM
Re: How can i implement something like poll()
see man 2 select
Regards
Rainer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2001 10:38 PM
09-05-2001 10:38 PM
Re: How can i implement something like poll()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2001 12:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2001 10:16 AM
09-06-2001 10:16 AM
Re: How can i implement something like poll()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2001 11:14 AM
09-06-2001 11:14 AM
Re: How can i implement something like poll()
The situation you describe seems to be a perfect fit for message queues. msgrcv() and msgsnd() will do just the king of blocking you seem to be looking for - unless you need to transfer fairly large amounts of data. You may be trying to avoid the overhead of the copies or you may need to transfer more than the maximum allowed message size. I may have a solution: Use message queues essentially as semaphores to handle the blocking but do the
actual data transfers (or pointer references to avoid the copy) in shared memory. This should give you the best of both worlds.
Food for thought, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2001 12:15 PM
09-06-2001 12:15 PM
Re: How can i implement something like poll()
if there is nothing on your queue, you could grab a mutext and add to a notification queue the thread id and signal you want. then when something later adds to your queue, it can notice that there were notifications regsitered and send your original thread a signal via pthread_kill. of course, this presumes the original thread registers a signal handler first :)
a variation would be that the original thread could register some form of FD instead of a signal under that notification mutex. say perhaps one end of a loopback TCP connection or a unix domain socket or something. then the thread that adds to the queue will write something - perhaps just a junk byte - perhaps something with more meaning - to the connection. the other thread then will see this if they are in a select() or poll() for other FD's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2001 12:25 AM
09-11-2001 12:25 AM