select(0,NULL,NULL,NULL,&t1) used for delay

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux