Main Page | Report this Page
 
   
Linux Forum Index  »  Linux Development - Applications  »  select system call queries...
Page 1 of 1    
Author Message
arnab...
Posted: Wed Aug 13, 2008 12:23 am
Guest
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
David Schwartz...
Posted: Wed Aug 13, 2008 9:13 am
Guest
On Aug 13, 3:23 am, arnab <agangul... at (no spam) gmail.com> wrote:

Quote:
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()

Yuck! Why?!

Quote:
I removed the locks of pthread_mutex_lock/and release as socket
libraries are thread safe.

Good.

Quote:
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?

I don't think I understand your question.

Quote:
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.

I still don't understand. What's your question exactly?

DS
...
Posted: Sun Aug 31, 2008 7:02 pm
Guest
On Aug 13, 6:23 am, arnab <agangul... at (no spam) gmail.com> wrote:
Quote:
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

Try 'select' with a timeout of 0 seconds if you really must use that
pattern. Why do you protect 'select' with a mutex? If that's *not*
what you're doing then you'll have a hard time convincing anyone that
the mutex is necessary.
Kevin P. Barry
 
Page 1 of 1       All times are GMT - 5 Hours
The time now is Mon Dec 01, 2008 9:06 pm