Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Process.setPriority()

> 
> 
> Well, that isn't bad but it doesn't really give you a lot of
> freedom.  It implies that HIGHEST is the upper bound and 
> LOWEST is the lower bound of possible priorities.  On QNX (as an
> example), a normally run process would have the range mapped to
> +53 to -9.  While on Windows this would be more accurate. 
> 
> So I still vote for the two APIs but I like the contants.  Perhaps
> we rename them to...
> 
> setPriority() and setAbsPriority() so that the shorter API is the
> one that does relative priority setting?
> 
>     chris
> 
> 
> On Wed, Jan 29, 2003 at 10:37:56AM -0500, Ed Burnette wrote:
> > May I suggest one routine, and some constants to go with it:
> > 
> > public int setPriority(int priority) { /* ... */ }
> > public final int PRIORITY_HIGHEST = 2;
> > public final int PRIORITY_ABOVENORMAL = 1;
> > public final int PRIORITY_NORMAL = 0;
> > public final int PRIORITY_BELOWNORMAL = -1;
> > public final int PRIORITY_LOWEST = -2;
> > 
> > (inspired by C# Thread.Priority property)
> > Not sure about the values (positive and negative) but having constants would be nice (no pun intended).
> > 

Actually having constants is a nice thing, it provides homogeneous to the
API and applications would not care of what is NORMAL/HIGH/LOW.
In Chris's example above, you would think that the NORMAL priority is
mid-way between +53 and -9 .. but it is not 8-) ..(glossing over details).
In java.Thread, the VM does take care of this for you by mapping it to
the correct prio, so we had to do the same thing.

But in the same breath, spawner is a peculiarity brought together because
it was not possible to do some things in java.  So I'm not sure all that
jazz is needed, by calling Spawner we are already in the red zone so
if a call is done with:
 setPriority(200);
We have to assume that the caller knows what he/she is doeing.

We could still do something like

 int setNormalizePriority(int priority_constants);

Hopefully the implementor will map this right.

Note: I'm not raising my hand to work on this, 8-) busy enough.


> > > -----Original Message-----
> > > From: Chris McKillop [mailto:cdm@xxxxxxx] 
> > > Sent: Tuesday, January 28, 2003 1:14 AM
> > > To: cdt-dev@xxxxxxxxxxx
> > > Subject: Re: [cdt-dev] Process.setPriority()
> > > 
> > > 
> > > On Mon, Jan 27, 2003 at 09:30:49AM -0800, Chris Songer wrote:
> > > > Hi!
> > > > 
> > > > I think you want both a relative and absolute actually. For 
> > > the fellow who 
> > > > wants to do something platform specific you let them pass 
> > > in a raw priority 
> > > > number. You also do what you suggest and have win32 like 
> > > settings, Low, 
> > > > BelowNormal, Normal, AboveNormal and High. If you just do 
> > > the latter then 
> > > > you've hosed the fellow who really needs control for some reason.
> > > > 
> > > 
> > > Actually, I was thinking more like this...
> > > 
> > > .setPriority( int val );
> > > .setRelativePriority( int delta );
> > > 
> > > 
> > > Then you have complete control, but without having to worry 
> > > about figuring
> > > out what the priority of the caller's process actually might be.
> > > 
> > > So, to emulate nice you could do...
> > > 
> > > .setRelativePriority( -1 );
> > > 
> > > ...but to be totally system specific...
> > > 
> > > .setPriority( 9 );
> > > 
> > > Just make sure to put a nice warning on the .setPriority() 
> > > value that it's
> > > meaning is system dependant and that (more) portable code 
> > > should use relative
> > > priorities. ;)
> > > 
> > >     chris
> > > 
> > > -- 
> > >   Chris McKillop <cdm@xxxxxxx>   "The faster I go, the 
> > > behinder I get."
> > >   Software Engineer, QSSL                   -- Lewis Carroll --
> > >   http://qnx.wox.org/
> > > 
> > > 
> > > _______________________________________________
> > > cdt-dev mailing list
> > > cdt-dev@xxxxxxxxxxx
> > > http://dev.eclipse.org/mailman/listinfo/cdt-dev
> > > 
> > _______________________________________________
> > cdt-dev mailing list
> > cdt-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/cdt-dev
> 
> -- 
>   Chris McKillop <cdm@xxxxxxx>   "The faster I go, the behinder I get."
>   Software Engineer, QSSL                   -- Lewis Carroll --
>   http://qnx.wox.org/
> 
> 
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-dev
> 


-- 
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!



Back to the top