[comp.os.os2.programmer] Raising a process's priority

hwb@nadia.stgt.sub.org (Harald Boegeholz) (05/04/91)

Hello, everybody!

I have a question about raising a process's priority. On my machine,
I run an OS/2-Version of UUPC/extended to transfer news and mail.
To optimize throughput, I have raised the process priority to
PRTYC_FOREGROUNDSERVER using DosSetPrty.

What I want to achive is this: the modem process should not be delayed
when I continue using the system interactively. Since OS/2 uses
dynamic priorities, the active window always gets a higher priority
than the other windows. A simple command like a directory listing
takes up almost all cpu time (scrolling in graphics mode keeps the
machine busy).

For my modem process, I want a priority slightly higher than that
of a foreground window, and I thought PRTYC_FOREGROUNDSERVER was
the right priority to achieve that.

One thing I don't understand: The PSTAT command seems to display
the priorities using a different (more internal?) coding than
DosGet/SetPrty. In this display, regular processes have a high
order byte of 2, my PRTY_FOREGROUNDSERVER process has 3, and the
CMD process of the active window has 4. Even more strangely, the
PSTAT command executing under that CMD has 031F, which is still higher
than my 0300. Values of the high order byte seem to range up to 8
here, which DosGetPrty reports as 3 (time critical).

Also, the DOS box seems to get a higher priority, too (which I can't
verify without leaving it :-( ).

Is there a way of setting process priority on a finer scale, say, to
5 in the internal coding used by PSTAT?

Or do I have to resort to PRTYC_TIMECRITICAL? Are there any objections
against using such a high priority in a user process?

Btw, the above applies to OS/2 1.3. Under OS/2 1.2 it seems to be pretty
much the same. Except that the PSTAT process runs at 071F.
Strange.

Somebody please enlighten me!

Harald

-- 
Harald Boegeholz |Home:       hwb@texnix.stgt.sub.org (read daily)
                 |University: boegehol@az3.informatik.uni-stuttgart.de
                 |please don't send large (>100k) mail to my home address.

lowey@herald.usask.ca (Kevin Lowey) (05/05/91)

hwb@nadia.stgt.sub.org (Harald Boegeholz):

> I have a question about raising a process's priority. On my machine,
> I run an OS/2-Version of UUPC/extended to transfer news and mail.
> To optimize throughput, I have raised the process priority to
> PRTYC_FOREGROUNDSERVER using DosSetPrty.
> 
> What I want to achive is this: the modem process should not be delayed
> when I continue using the system interactively. Since OS/2 uses
> dynamic priorities, the active window always gets a higher priority
> than the other windows. A simple command like a directory listing
> takes up almost all cpu time (scrolling in graphics mode keeps the
> machine busy).

There are better ways to fix this than to hard code it into the program. 
I suggest adding this line to CONFIG.SYS:

PRIORITY=ABSOLUTE

This disables the dynamic priorities and instead leaves everything at their
default base priorities all the time.  This lets background tasks get a 
higher percentage of the CPU than with dynamic priorities.

If you want to leave the dymanic option on, you can change the MAXWAIT 
option in CONFIG.SYS.  This controls the maximum amount of time a process
must wait before it's priority is dynamically increased.  A shorter time 
ensures that a process will get control back sooner when dynamic priorities
are set.
 
You may also want to change the TIMESLICE option in CONFIG.SYS.  TIMESLICE 
controls the minimum and maximum amount of CPU time a process gets before it 
is forced to give up the CPU.  The default is about 250 milliseconds maximum.
Communications programs work a bit better if the maximum is reduced to 
about 100 milliseconds.

See your OS/2 manuals, or the on-line command reference for more details.

- Kevin Lowey