From: Shane K. <sh...@ti...> - 2002-01-28 13:19:23
|
Jeff & Co., I saw a report of threading problems on the user list, but I'm not currently on that list. And this doesn't seem too related. Anyway... I just downloaded and compiled a kernel with uml-patch-2.4.17-9.bz2, and booted up the Red Hat 7.2 image. It consumed 100% of the CPU all of the time. I shut down various services, and eventually got it to run idle. The problem turned out to be that any program running pthreads spins. Here's a short sample: *** begin foo.c *** #include <pthread.h> #include <stdio.h> void * thread (void *dummy) { for (;;) { sleep(60); } } int main () { pthread_t tid; if (pthread_create(&tid, NULL, thread, NULL) != 0) { fprintf(stderr, "Error %d creating thread\n"); return 1; } pthread_join(tid, NULL); return 0; } *** end foo.c ** Run with: $ gcc -o foo foo.c -lpthread $ ./foo UML has two threads, one using 2/3 of the CPU, the other the remaining 1/3. Additionally, the threads appear to ignore any signal but SIGKILL, although the parent process gets a return from wait(). Needless to say, this program consumes no CPU when run under the host kernel. ;) -- Shane Carpe Diem |