* tike64 <[email protected]> wrote:
> I made my test code visible if you want to take a look: www dot
> riihineva dot no-ip dot org uphill public uphill test-rt.c
on x86, with nanosleep i get:
# ./test-rt
100 revs; min: 5026 max: 5099 avg: 5062
100 revs; min: 5031 max: 5105 avg: 5065
100 revs; min: 5021 max: 5096 avg: 5048
100 revs; min: 5014 max: 5080 avg: 5041
100 revs; min: 5015 max: 5072 avg: 5040
100 revs; min: 5018 max: 5075 avg: 5041
100 revs; min: 5021 max: 5091 avg: 5042
with select i get:
# ./test-rt
100 revs; min: 4276 max: 6048 avg: 5181
100 revs; min: 4371 max: 6060 avg: 5438
100 revs; min: 4409 max: 6056 avg: 5338
100 revs; min: 4940 max: 6056 avg: 5468
100 revs; min: 4938 max: 6049 avg: 5398
100 revs; min: 4373 max: 6056 avg: 5279
100 revs; min: 4943 max: 6040 avg: 5068
(HZ=250 on this kernel)
so these results look pretty normal to me. Modified code attached below.
(Change the '#if 1' to '#if 0' to get the select() measurement.)
Ingo
----------------->
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <limits.h>
#include <sched.h>
#include <time.h>
#include <sys/time.h>
#include <sys/mman.h>
static unsigned raw_timer(void)
{
struct timeval tv;
gettimeofday(&tv, 0);
return tv.tv_sec * 1000000 + tv.tv_usec;
}
int main(int argc, char *argv[])
{
int t, min_t = INT_MAX, max_t = INT_MIN, avg_t = 0, n = 0;
struct timespec ts;
struct timeval tv;
struct sched_param prio;
prio.sched_priority = 99;
if (sched_setscheduler(0, SCHED_RR, &prio) < 0) {
perror("setscheduler failed"); }
if (mlockall(MCL_CURRENT | MCL_FUTURE) < 0) {
perror("mlockall failed"); }
while (1) {
t = raw_timer();
ts.tv_nsec = 5000000;
ts.tv_sec = 0;
#if 1
nanosleep(&ts, 0);
#else
tv.tv_usec = 5000;
tv.tv_sec = 0;
select(0, 0, 0, 0, &tv);
#endif
t = raw_timer() - t;
if (max_t < t) max_t = t;
if (min_t > t) min_t = t;
avg_t += t;
++n;
if (n < 100)
continue;
printf("%i revs; min: %i max: %i avg: %i\n", n, min_t, max_t, (avg_t + n / 2) / n);
fflush(stdout);
min_t = INT_MAX;
max_t = INT_MIN;
avg_t = 0;
n = 0;
}
}
-
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]