Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

select system call queries

0 views
Skip to first unread message

arnab

unread,
Aug 13, 2008, 6:24:47 AM8/13/08
to
Hi All,
I have the following code snippet.
pthread_mutex_lock()
select()-> for read file descriptors with timeout of 25 sec
accept()
pthread_mutex_release()

I removed the locks of pthread_mutex_lock/and release as socket
libraries are thread safe.
Now my question is there a possibility of hang in the select function
when read file descriptors are not available?Also can the timeout of
25 sec contribute to the hang?
How can I check the read_fds are not available or the threshold is
being reached.
Any comments or suggestions would be very much appreciated.
Thanks
Arnab

Andrei Voropaev

unread,
Aug 15, 2008, 5:14:59 PM8/15/08
to
On 2008-08-13, arnab <agang...@gmail.com> wrote:
> select()-> for read file descriptors with timeout of 25 sec
> accept()
>
> Now my question is there a possibility of hang in the select function
> when read file descriptors are not available?Also can the timeout of
> 25 sec contribute to the hang?
> How can I check the read_fds are not available or the threshold is
> being reached.
> Any comments or suggestions would be very much appreciated.

Your question is not clear. What do you mean by "possibility of hang"?
select is supposed to block the thread untill one of the descriptors
becomes ready. There is common mistake with select when people forget to
initiate the descriptors set before EVERY call to select, as result the
select gets no descriptors and just sits there till time-out expires.
See if you make such mistake. Though I recommend you to buy book of
Stevens "Unix network programming" Volume 1. After reading it you'll get
the answers to all your questions.

--
Minds, like parachutes, function best when open

arnab

unread,
Aug 19, 2008, 3:55:58 AM8/19/08
to
On Aug 16, 2:14 am, Andrei Voropaev <avo...@mail.ru> wrote:

Thanks for all help.Actually so far my observation,I have seen under
the heavy load of the server it pauses in the select system call for
some secs.I have a select on the read file descriptor with timeout as
25 sec save.This behavior is never observed when the load on the
server is less.

Is it like under the heavy load the read descriptors are not available
for which it pauses and waits for the timeouts?Within that timeout if
it gets it will proceed?Let me know your views?Also is there a way to
find out whether my descriptors upper limit value is reached hence no
more available ?Also how do I increase the descriptors ?Do I need to
modify FD_SETSIZE?
Thanks in advance.
Arnab

0 new messages