In linux 2.3.39, if the CPU is given up by calling sched_yield(), even
though the caller may give up the CPU for many milliseconds, `top`
still shows that the caller is using 99% of the CPU time.
This shows the problem:
#include <stdio.h>
#include <sys/time.h>
#define MICRO 1e6
main()
{
struct timeval tv;
double start;
double stop;
double total;
for(;;)
{
gettimeofday(&tv, NULL);
start = ((double) tv.tv_sec * MICRO) + (double) tv.tv_usec;
sched_yield();
sched_yield();
sched_yield();
sched_yield();
sched_yield();
sched_yield();
sched_yield();
sched_yield();
sched_yield();
sched_yield();
gettimeofday(&tv, NULL);
stop = ((double) tv.tv_sec * MICRO) + (double) tv.tv_usec;
total = stop - start;
fprintf(stderr,"TT %8.2f us\n", total);
}
}
Now sched_yield(), itself, works well. The problem is that the task
that gave up the CPU is still being 'Charged' for it!
Cheers,
Dick Johnson
Penguin : Linux version 2.3.39 on an i686 machine (800.63 BogoMips).
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sun Jan 23 2000 - 21:00:20 EST