public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* select() for delay.
@ 2005-10-24 10:55 madhu.subbaiah
  2005-10-24 13:18 ` Steven Rostedt
  2005-10-30 19:06 ` Arnd Bergmann
  0 siblings, 2 replies; 8+ messages in thread
From: madhu.subbaiah @ 2005-10-24 10:55 UTC (permalink / raw)
  To: linux-kernel

Hi all,

This is regarding select() system call.

Linux select() man page mentions " Some  code  calls  select with all
three sets empty, n zero, and a non-null timeout as a fairly portable
way to sleep  with  subsecond  precision".

This patch improves the sys_select() execution when used for delay. 

Kindly suggest.


--- linux-2.4.22/fs/select.c    2003-06-13 20:21:37.000000000 +0530
+++ linux/fs/select.c   2005-10-20 15:01:38.000000000 +0530
@@ -286,6 +286,29 @@ sys_select(int n, fd_set *inp, fd_set *o
        if (n < 0)
                goto out_nofds;
 

+       if ((n == 0) && (inp == NULL) && (outp == NULL) && (exp ==
NULL)) {
+                set_current_state(TASK_INTERRUPTIBLE);
+                ret = 0;
+                timeout = schedule_timeout(timeout);
+

+                if (signal_pending(current))
+                        ret = -ERESTARTNOHAND;
+

+                if (tvp && !(current->personality & STICKY_TIMEOUTS)) {
+                        time_t sec = 0, usec = 0;
+                        if (timeout) {
+                                sec = timeout / HZ;
+                                usec = timeout % HZ;
+                                usec *= (1000000 / HZ);
+                        }
+                        put_user(sec, &tvp->tv_sec);
+                        put_user(usec, &tvp->tv_usec);
+                }
+

+                current->state = TASK_RUNNING;
+                goto out_nofds;
+        }
+
        /* max_fdset can increase, so grab it once to avoid race */
        max_fdset = current->files->max_fdset;
        if (n > max_fdset)

Thanks,
Madhu K.S.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-10-31 15:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-24 10:55 select() for delay madhu.subbaiah
2005-10-24 13:18 ` Steven Rostedt
2005-10-24 13:27   ` Arjan van de Ven
2005-10-24 13:37     ` Steven Rostedt
2005-10-25  6:26     ` Madhu K.S.
2005-10-30 19:06 ` Arnd Bergmann
2005-10-30 19:12   ` Arjan van de Ven
2005-10-31 15:46   ` Christopher Friesen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox