public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* select(0,NULL,NULL,NULL,&t1) used for delay
@ 2005-10-06 13:49 Madhu K.S.
  2005-10-06 14:25 ` Jesper Juhl
  2005-10-06 14:27 ` Alex Riesen
  0 siblings, 2 replies; 11+ messages in thread
From: Madhu K.S. @ 2005-10-06 13:49 UTC (permalink / raw)
  To: linux-kernel

Hi all,


In many application we use select() system call for delay.

example:
select(0,NULL,NULL,NULL,&t1);


select() for delay is very inefficient. I modified sys_select() code for
efficiency .Here are the changes to fs/select.c.

Please suggest on these changes. 

I know nanosleep() can be used instead of select(), but please suggest
on my changes.


file : fs/select.c
function : sys_select()




                          timeout += sec * (unsigned long) HZ;
                }
        }
-
+
+
        ret = -EINVAL;
        if (n < 0)
                goto out_nofds;
-
+       if ( (n == 0) && (inp == NULL) && (outp == NULL) &&
		(exp==	NULL)){
+                printf("\n I am inside new select condition timeout
			%d\n",timeout);
+                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)



Thank you very much.
Thanks for your assistances.

Madhu K.S.


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

end of thread, other threads:[~2005-10-10 18:05 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-06 13:49 select(0,NULL,NULL,NULL,&t1) used for delay Madhu K.S.
2005-10-06 14:25 ` Jesper Juhl
2005-10-06 14:28   ` Jesper Juhl
2005-10-06 19:05   ` Howard Chu
2005-10-06 19:41     ` Christopher Friesen
2005-10-06 14:27 ` Alex Riesen
2005-10-06 15:26   ` Christopher Friesen
2005-10-06 15:42     ` Bernd Petrovitsch
2005-10-06 15:57       ` Christopher Friesen
2005-10-06 17:30     ` Bob Copeland
2005-10-10 18:06   ` Bill Davidsen

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