Re: select takes too much time

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

 



On Thu, 13 Apr 2006, Ram Gupta wrote:

> On 4/13/06, Michal Schmidt <[email protected]> wrote:
>> Ram Gupta wrote:
>>> I am using 2.5.45 kernel but I believe the same would  be the true
>>> for the latest kernel too.
>>
>> Are you just assuming this, or did you actually try a recent kernel?
>>
>> Michal
>>
>
> I didn't get a chance to try it on a recent kernel yet but I believe
> it to be so though I may be  wrong
>
> Ram
> -

Simple program here shows that you may be right! In principle,
I should be able to multiply the loop-count by 10 and divide
the sleep time by 10, still resulting in 1-second total time
through the loop. Not so! Changing the value, marked "Change this" to
a smaller value doesn't affect the time very much. It is as though
the sleep time is always at least 1000 microseconds. If this is
correct, then there should be some kind of warning that the time
can't be less than the HZ value, or whatever is limiting it.


#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/select.h>

#define USEC 1e6

int main()
{
     struct timeval tv,tod;
     size_t i;
     double start_time, end_time, total_time;
     for(;;) {
         gettimeofday(&tod, NULL);		// Start time in useconds
         start_time = ((double)tod.tv_sec * USEC) + (double)tod.tv_usec;
         for(i=0; i< 1000; i++) {
             tv.tv_sec = 0;
             tv.tv_usec = 1000;		// <--- change this
             select(0, NULL, NULL, NULL, &tv);
         }
         gettimeofday(&tod, NULL);		// End time in useconds
         end_time = ((double)tod.tv_sec * USEC) + (double)tod.tv_usec;
         total_time = (end_time - start_time) / USEC;
         printf("Total time = %f seconds\n", total_time);
     }
     return 0;
}



Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.54 BogoMips).
Warning : 98.36% of all statistics are fiction, book release in April.
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
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