For those times when a threaded program runs amok, and I still have some hope that it will eventually stop being a pig, but would like to actually use my computer in the meanwhile, the idea of renicing this runaway program to nice 19 comes to mind.
Except, it doesn't actually work. Only the main thread seems to get reniced, and the threads created with pthread_create seem to merrily go on with their plundering of CPU cycles. Test code at the end of the mail. To reproduce this, I start the test program, and observe in top that it is indeed consuming all CPU like it was intended to. Then I renice it in top, to nice 19. Effect is, '% ni value in top still stays the same, and these hog threads are still consuming nearly all CPU and not sharing with other nice 19 processes, indicating that they were not reniced to 19. Tested on Fedora Core 2's kernel 2.6.10-1.9 + procps 3.2.5 from sf.net Tested on kernel 2.6.10-ck4 + procps 3.2.1 Here for the test case: #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #define THREADS 10 void *hog(void*p); int main(int argc, char** argv) { pthread_t *threads; int i; threads = malloc(sizeof(pthread_t) * THREADS); for(i=0;i<THREADS;i++) pthread_create(&threads[i], NULL, hog, NULL); fprintf(stderr, "The hogs are loose!\n"); while(1) sleep(3600); } void *hog(void*p) { fprintf(stderr, "Oink oink!\n"); while(1); } - 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/