[comp.windows.x] Process priorities and X

de5@STC06.CTD.ORNL.GOV (SILL D E) (07/04/90)

A user on a DG Aviion is complaining that background jobs run by cron
are running at higher priorities than X clients, e.g., ps shows the
server at 20, the background job at 22, and xterm at 24.  Apparently,
this background job is a number cruncher that's been running for a few
days.  Interactive response is, needless to say, negatively impacted
by running at a lower priority than the `batch' job.

My questions are:
    -does the DG, or do SYS V systems in general, have `renice'?
        (the only SYS V machine I have access to, a Cray X-MP, doesn't
        have it, but I don't know if that's typical SYS V.)
    -anyone else seen this behavior on DG's or under X on other
        systems?  (I've never seen it on Suns or DECs, but then I
        don't run heavy-duty background jobs.)
    -aren't long-running jobs automatically nice'd by the kernel?
    -is there any way to boost the priority of X clients at
        invocation-time other than `nice -N xclient...'?

[Comp.unix.question readers: please reply by mail.]

Thanks.

--
Dave Sill (de5@ornl.gov)
Martin Marietta Energy Systems
Workstation Support

rmtodd@servalan.uucp (Richard Todd) (07/04/90)

de5@STC06.CTD.ORNL.GOV (SILL D E) writes:
>A user on a DG Aviion is complaining that background jobs run by cron
>are running at higher priorities than X clients, e.g., ps shows the
>server at 20, the background job at 22, and xterm at 24.  Apparently,

  Is said user, by any chance, using twm?  I'm running X11R4 with twm on a
Mac IIx, and I've noticed that clients that are started from twm (by some
twm menu action) are niced down by 4, and clients that are started by hand
run at normal niceness.  

  Reading this message, I decided to do some investigating (i.e. grepping thru
the source...)  I couldn't find a single call to nice() (the syscall that
lowers process priority) anywhere in the twm or Xlib source; "nm twm" doesn't
even list nice!  Obviously the clients twm starts are lowering themselves in
priority somehow, but I don't see how.  Something weird's going on here,
folks.

>My questions are:
>    -does the DG, or do SYS V systems in general, have `renice'?

  In general, no, SysV systems don't support renice, because they don't 
support the appropriate system call (setpriority(), I believe).  
The only way to change the process priority is a. when it starts or b. by
writing a program to fiddle the priority fields in the kernel process table
in /dev/kmem directly.  I've done the latter (being fed up with A/UX's lack of
renice), but it's ugly.  Boy is it ugly.  Not to mention that writing to
/dev/kmem is not an activity for the timid....

>    -anyone else seen this behavior on DG's or under X on other
>        systems? 

  See above.  

>    -aren't long-running jobs automatically nice'd by the kernel?

	They are on BSD systems.  I've never seen it happen on my Mac, so 
I suspect it isn't true on SysV in general.

>    -is there any way to boost the priority of X clients at
>        invocation-time other than `nice -N xclient...'?

   Even that won't boost your priority if you're not root, at least not on
any Unix I'm familiar with -- non-root users can only make their priorities
worse, not better.  

   You could always go and change your startup script/inittab/whatever to
make cron do its stuff at really bad priority, though...

--
Richard Todd	rmtodd@uokmax.ecn.uoknor.edu  rmtodd@chinet.chi.il.us
	rmtodd@servalan.uucp

dce@smsc.sony.com (David Elliott) (07/04/90)

In article <1990Jul4.061431.12129@servalan.uucp> rmtodd@servalan.uucp (Richard Todd) writes:
>  Is said user, by any chance, using twm?  I'm running X11R4 with twm on a
>Mac IIx, and I've noticed that clients that are started from twm (by some
>twm menu action) are niced down by 4, and clients that are started by hand
>run at normal niceness.  

This makes sense.  All twm does is to system() the command to be
executed, so it is subject to the same rules as any command executed
by /bin/sh.

In System V.2 and better versions of sh, the default is to automatically
nice down (by 4) all processes started in the background.

In other words, it probably isn't twm starting the processes at a
lower priority, but the shell.  If you have source for sh, you can
recompile it to not nice down background jobs.  Another option is
to write your own "background" command that runs, using the shell,
the command[s] you need in the background (by forking and redirecting
the process itself, instead of giving a & to the shell).
as arguments 
-- 
David Elliott
dce@smsc.sony.com | ...!{uunet,mips}!sonyusa!dce
(408)944-4073
"If I had a hat the size of Oklahoma, I'd be a happy person."

goudreau@larrybud.rtp.dg.com (Bob Goudreau) (07/06/90)

In article <1990Jul4.061431.12129@servalan.uucp>, rmtodd@servalan.uucp
(Richard Todd) writes:
> 
> >My questions are:
> >    -does the DG, or do SYS V systems in general, have `renice'?
> 
>   In general, no, SysV systems don't support renice, because they don't 
> support the appropriate system call (setpriority(), I believe).  

But in the case of DG/UX, yes.  DG/UX is a merge of Sys V and BSD
features, and it supports getpriority()/setpriority() and nice(1).

------------------------------------------------------------------------
Bob Goudreau				+1 919 248 6231
Data General Corporation
62 Alexander Drive			goudreau@dg-rtp.dg.com
Research Triangle Park, NC  27709	...!mcnc!rti!xyzzy!goudreau
USA

gary@dgcad.SV.DG.COM (Gary Bridgewater) (07/06/90)

In article <1990Jul4.160042.562@smsc.sony.com> dce@Sony.COM (David Elliott) writes:
}In article <1990Jul4.061431.12129@servalan.uucp> rmtodd@servalan.uucp (Richard Todd) writes:
}}... and I've noticed that clients that are started from twm (by some
}}twm menu action) are niced down by 4, and clients that are started by hand
}}run at normal niceness.  
}This makes sense.  All twm does is to system() the command to be
}executed, so it is subject to the same rules as any command executed
}by /bin/sh.
}In System V.2 and better versions of sh, the default is to automatically
}nice down (by 4) all processes started in the background.

(X11R3 uwm has the same property)

I just invoke the following set-root script from my initializer script.  If the
window manager is a nice -4 then sons exec'd with a nice 4 will have a net
niceness of 0.  Friendly system managers can set this up for users.  Substitute
the windowmanager of your choice or make it an argument.  Probably everyone can
make a better one than this but it works for me on my AViiON.
(Note: having a nice -4 window manager makes it quite snappy.)

//
#!/bin/sh
# raise window manager priority
exec renice -4 `ps -e | grep uwm | cut -c1-6` >> /dev/null 2>&1
-- 
Gary Bridgewater, Data General Corporation, Sunnyvale California
gary@sv.dg.com or {amdahl,aeras,amdcad}!dgcad!gary
C++ - it's the right thing to do.

bros@convex.com (07/06/90)

In article <1990Jul4.160042.562@smsc.sony.com>, dce@smsc.sony.com (David
Elliott) writes:

> In System V.2 and better versions of sh, the default is to automatically
> nice down (by 4) all processes started in the background.
> 
> In other words, it probably isn't twm starting the processes at a
> lower priority, but the shell.  If you have source for sh, you can
> recompile it to not nice down background jobs.  Another option is
> to write your own "background" command that runs, using the shell,
> the command[s] you need in the background (by forking and redirecting
> the process itself, instead of giving a & to the shell).
> as arguments 

The korn shell (ksh) has an option called "bgnice" which may be turned
off to prevent background jobs being niced.  You might check if your
shell has a similar option.


Andrew Bros				bros@convex.com
Product Engineering			or try:
Convex [Super]Computer Corp.		ab27@andrew.cmu.edu