mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Knutar <jk-lkml@sci.fi>
To: linux-kernel@vger.kernel.org
Subject: Impossible to renice threaded NPTL programs on 2.6.10
Date: Sat, 29 Jan 2005 05:36:57 +0200	[thread overview]
Message-ID: <200501290536.59393.jk-lkml@sci.fi> (raw)

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

                 reply	other threads:[~2005-01-29  3:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200501290536.59393.jk-lkml@sci.fi \
    --to=jk-lkml@sci.fi \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®