select vs poll


 
Thread Tools Search this Thread
Special Forums IP Networking select vs poll
# 1  
Old 04-26-2007
select vs poll

Hi,

Off late I had been looking at the differences b/w select() & poll() system calls. The requirement is to reduce the overhead, processor power in waiting for the data. In the kind of connections under consideration there would be very frequent data arriving on the sockets, so poll() fares well.

But!!! Even in the few millisec when the data is not arriving, the application can do something better! So will select() be a better function to go for?

In that case will there be any performance improvement at all?

Instead, is there a scope for some kind of asynchronous call back functions where the appliction will just be initimated in case data arrives.

On the whole, the requirement is that unnecessary waiting time should be cut & perfromance improved!

If this is not the right forum, can somebody suggest the right one.

Thanks in advance!!!
# 2  
Old 04-26-2007
In many cases the choice is made for you.

If the system is BSD derived, then use select. In this case poll is merely a wrapper around select.

If the system is System V derived, then use poll. In this case select is merely a wrapper around poll.

The main advantage of poll is the number of file descriptors is not limited by the size of fd_set, other than that there is no real difference.

Just because you can specify the time in microseconds or nanoseconds does not mean the OS will honour those, they are still limited by the system/heartbeat clock frequency.

Last edited by porter; 04-27-2007 at 05:57 AM..
# 3  
Old 04-27-2007
Completion Ports

Hi,
I dont know which platform your are working on. But of the query,
Quote:
Originally Posted by smanu
is there a scope for some kind of asynchronous call back functions where the appliction will just be initimated in case data arrives.
I guess for solaris 10 (Sun OS 5.10), there is a new amenity called "Completion Ports". I wonder if this may be useful for you. I dont have much background on this feature. But on quick glance at it, I guess it is a type of asynchronous request handler.

Excuse me if the information is misleading/away from the topic...

Thanks
Srini
# 4  
Old 04-27-2007
Hi,

Srinivasan: Thanks for the information. That was exactly something I was looking out for. Do you by any chance have any idea about how much performance improvement can be achieved by replacing poll with Asynchronous I/O framework.

Porter: How do I check if my system is BSD derived or V derived?

/smanu.
# 5  
Old 04-28-2007
Quote:
Originally Posted by smanu
Porter: How do I check if my system is BSD derived or V derived?
There are a number of ways but here we are trying to find out if select or poll is the more fundamental call. A suggestion is to look at sys/syscall.h and see if SYS_select or SYS_poll exist. If both exist then *maybe* both are native, but for instance not in the case of Darwin. In that case you could check to see which is the "earlier" call, ie if SYS_select is less than SYS_poll.
# 6  
Old 04-28-2007
Ok! My syscall.h has got SYS_poll only.
So poll() seems to be the primitive one.

But could you tell me what are those other number of ways in which we can check if our system is BSD derived or V derived?
# 7  
Old 04-28-2007
Quote:
Originally Posted by smanu
But could you tell me what are those other number of ways in which we can check if our system is BSD derived or V derived?
Off the top of my head the three main differences for a programmer are:

1. STREAMS

if has #include <sys/stream.h> it's SYS V

2. signals

if it has sigblock & sigsetmask it's BSD, if sighold & sigrelse it's SYS V

3. terminal handling

check prototype for "setpgrp()", if takes two args it's BSD


But as systems have all adopted BSD sockets and merging to standardisation on posix compatibility it is more important to check the actual feature you are trying to use.
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

Powerhouses and mainstream poll

This not a joke but a quite serious question to maybe have your point of view about this very topic of content on the net. So I start this poll to ask the users if they can imagine that the so called content industry of former times sooner or later or anyway will regain lost ground or not? Do you... (1 Reply)
Discussion started by: 1in10
1 Replies

2. Shell Programming and Scripting

How to use poll() for I/O multiplex

Hi, guys: I want to write my own shell using C. I am confused about the usage of I/O multiplex. Does anyone know some examples or explain it to me ? Thanks so much (1 Reply)
Discussion started by: tomlee
1 Replies

3. Shell Programming and Scripting

how to poll for new files?

Hi , i have a requirement in which i have to ftp files to unix from windows and vice versa. I have to encrypt files in windows which will then be decrypted in unix and vice versa. Now the process needs to be automated ..therefore when windows server or unix server recieves the files a shell... (5 Replies)
Discussion started by: lifzgud
5 Replies

4. UNIX for Dummies Questions & Answers

Poll data from a file

I have to write a script where I poll a txt file for data (30 min interval) Dependent on the data read, the script should return a message. It should look something like the "code" below: -- do while <data recived> sleep 30m read data from file Done If <data> x return "A" If... (1 Reply)
Discussion started by: ioniCoder
1 Replies

5. Programming

select/poll and Signal Safety

Hi I am struggling to understand why one should use pselect()/ppoll() instead of wrapping an ordinary select() or poll() call around sigprocmask(). The linux man page talks about “race conditions”, but how would such dangers occur? I plan to use poll() for an application (since ppoll() isn't... (0 Replies)
Discussion started by: nopcoder
0 Replies

6. UNIX for Dummies Questions & Answers

Replace select/poll with kqueue/kevent

Hi, As far as I known, kqueue/kevent model can be used to improve the efficiency of systems event dispatching. I m wondering whether kqueue/kevent is same as the real-time OS event model. I also want to know when writing multiplexing app in real-time OS, what APIs need to be used for... (1 Reply)
Discussion started by: bsderss
1 Replies

7. Programming

How to convert the "select" function into a "poll" function

i have a program using the select function but i want to convert it to poll... how can i do this? thanks in advance... :) (1 Reply)
Discussion started by: rbolante
1 Replies
Login or Register to Ask a Question