[lkml]   [2002]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Linux Kernel Patch; setpriority
  Rather than expect people who have been following this to reread I'll
put this here. I believe the capability of nice(2) setting and restoring
is (a) very seldom useful given the new scheduler, and (b) can be done
with a bit of effort and no assult on SUS by doing the nice work in a nice

Code is attached.

On Wed, 27 Mar 2002, Chris Wright wrote:

> * Stephen Baker ( wrote:
> >
> > This patch will allow a process or thread to changes it's priority
> > dynamically based on it's capabilities. In our case we wanted to use
> > threads with Linux. To have true priorities we need root to use
> > SCHED_FIFO or SCHED_RR; in many case root access is not allowed but we
> > still wanted priorities. So we started using setpriority to change a
> > threads priority. Now we used nice values from 19 to 0 which did not
> > require root access. In some cases a thread need to raise it's nice
> > level and this would fail. I also saw a note man renice(8) that said
> > this bug exists.
> hmm, SUS v3 seems to disagree.
> "Only a process with appropriate privileges can lower its nice value."
> and with this patch setpriority(2) is now inconsistent with nice(2)
> (albeit i don't know how much longer that interface will persist in arch
> independent portion of the kernel based on the comments surrounding it).

bill davidsen <>
CTO, TMR Associates, Inc
Doing interesting things with little computers since 1979.
/* try changing nice(2) for a single thread */

#include <stdio.h>
#include <unistd.h>
#include <pthread.h>

int pid;
void part1(int *);
pthread_mutex_t print_lock = PTHREAD_MUTEX_INITIALIZER;
#define MAX_LOOP 100

main(int argc, char *argv[])
int j, stat;
volatile int i = 0;
pthread_t thrd1;

pid = getpid();
fprintf(stderr, "parent pid: %d\n", pid);
pthread_create(&thrd1, NULL, (void *)part1, (void *)&i);
/* note that I am not doing a damn thing here */
pthread_join(thrd1, NULL);

fprintf(stderr, "Normal termination\n");

part1(int *ix)
/* do one ps before nice(2) call */
system("ps l");
/* now be nice and try again */
fprintf(stderr, "\n--> nice\n");
system("ps l");
 \ /
  Last update: 2005-03-22 13:25    [W:0.048 / U:0.796 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site