Newsgroups: comp.parallel.pvm
From: fox@nrlssc.navy.mil (Dan Fox)
Subject: Re: Keeping other Workstation users happy ! - How ?
Organization: Naval Research Lab
Date: Thu, 11 Aug 1994 23:36:04 GMT
Message-ID: <CuE9K5.1r3@usenews.nrlssc.navy.mil>

Dr. Jan Pedersen (jan@mbisgi.umd.edu) wrote:

: I find  PVM and other message passing platforms a brave new world,
: and have had good scientific experiences with programs paralellised
: and run on large networks of heterogenous work-stations.

: The only problem I have is to keep other users happy, UNIX is
: unfortunately a terrible operating system for handeling many

I'm not sure I'd agree with that completely...  The "nice" value
is one way of controlling the relative load of many processes.
We routinely do all sorts of applications across networks of Suns
during the day, but run things at a high nice value so as not
to interfere with interactive use.

Since pvm doesn't have a "built-in" niceness, I find I have to
make sure all my pvm programs re-nice themselves right away
when they start running.  So each program (master, slave, task
whatever) starts off by calling a little C routine (which is
also callable from Fortran the way it's written) to renice
itself.  (Note: if you're programming in C directly, you can toss
90% of this and just call the "setpriority" function directly,
but I mostly still program in fortran, so the dual-entry option
with this function was needed...)



/* --------------------------------------------------------------
   PRIORITY :  a set of routines to permit FORTRAN programs to
   determine their current priority (NICE value) and set a
   new value.

   The two functions are:

		getnice  : to determine the current priority

		setnice  : to set the priority

   Note: the more positive the nice value, the lower the priority.
   The user may not decrease the nice value (that is, increase the
   priority) of a job (only superuser can do that).  The "most nice"
   value is 19.

   Typical usage:

		integer getnice, setnice
		...

		nice = getnice()
		nice = nice + 10
		ierr = setnice(nice)
		...

   dan fox / naval research laboratory / code 7320 / 21DEC93

   NOTE:  compile this with an ansi C compiler, like GCC
   -------------------------------------------------------------- */


/* --------------------------------------------------------------
   getnice
   --------------------------------------------------------------
   Routine to permit FORTRAN programs to determine their
   current priority (nice) value.

   Usage:

		integer getnice
		....
		nice = getnice()

   -------------------------------------------------------------- */

#include <stdio.h>
#include <sys/time.h>
#include <sys/resource.h>

int getnice()
{
	int who, nice ;
	who = 0 ;
	nice = getpriority(PRIO_PROCESS,who) ;
	return nice ;
}

int getnice_()
{
  return getnice() ;
}

/* --------------------------------------------------------------
   setnice
   --------------------------------------------------------------
   Routine to permit FORTRAN programs to set a new NICE value
   for themselves.  The NICE value cannot be lowered (i.e.,
   priority increased) and cannot be increased beyond 19.

   Usage:

		integer getnice,setnice

		nice = getnice()
	
		nice = nice + 10

		ierr = setnice(nice)
   -------------------------------------------------------------- */

int setnice( int *nice )
{
	int who, code ;
	who = 0 ;
	code = *nice ;
	code = setpriority(PRIO_PROCESS,who,code) ;
	return code ;
  
}

int setnice_( int *nice )
{
  return setnice(nice) ;
}




--
 +-----------------------------------------+
 | Daniel N Fox       fox@nrlssc.navy.mil  |
 | Naval Research Laboratory, Code 7323    |
 | Stennis Space Center, MS 39529-5004     |
 +-----------------------------------------+

