sched_yield() version 2.4.24

From: Richard B. Johnson
Date: Tue Mar 30 2004 - 11:48:31 EST



Anybody know why a task that does:

for(;;)
sched_yield();

Shows 100% CPU utiliization when there are other tasks that
are actually getting the CPU? It seems that a caller to
sched_yield() does not show that it is sleeping for any
portion of the time it gives up the CPU. On the other hand,
if usleep(0) is substituted, the task is shown to be sleeping.

This shows that the accounting for sched_yield() is mucked
up. It works fine, it gives up the CPU to other tasks. However,
`top` shows it as a CPU hog, which it isn't.

Simple code to check it out:

extern void sched_yield(void);
extern int usleep(int);
int main()
{
#if BAD
for(;;)
sched_yield();
#endif
for(;;)
usleep(0);
}

Cheers,
Dick Johnson
Penguin : Linux version 2.4.24 on an i686 machine (797.90 BogoMips).
Note 96.31% of all statistics are fiction.


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