mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Impossible to renice threaded NPTL programs on 2.6.10
@ 2005-01-29  3:36 Jan Knutar
  0 siblings, 0 replies; only message in thread
From: Jan Knutar @ 2005-01-29  3:36 UTC (permalink / raw)
  To: linux-kernel

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);
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-01-29  3:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-29  3:36 Impossible to renice threaded NPTL programs on 2.6.10 Jan Knutar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®