Visit the NICE/2 Homepage!








NICE/2

By Sharon Dagan <idagan@il.ibm.com>



What is NICE/2?

Have you ever started a long XCOPY command that ate too much CPU? Have you ever wanted to make Netscape/2 more responsive? NICE/2 is here to rescue. With NICE/2 you can dynamically change the priority of many processes in OS/2. As opposed to programs such as SPE that start a process in a given priority, NICE/2 enables you to change the priority of processes and threads after they have been started.

Jump to [Installation] [Basic] [Advanced] [Utilities] [SDK] [Known Problems] [Error codes]


Installation

Simply put \nice\dll in your LIBPATH and \nice\bin in your PATH.




Basic

NICE/2 is divided into three components: Server, GUI client and command line client. To start using NICE/2, the server must be running. To start the server, issue the command:

niced.exe -start

This will attempt to start the server. If everything went ok, niced.exe quietly returns. If the server could not be started, niced.exe reports the error and aborts the operation. To find out if the server is running or not, issue:

niced.exe

This will tell you if the server is running or not. To stop the server, issue:

niced.exe -stop

This will attempt to stop the server. This might take a few seconds. If the server was successfully stopped, niced.exe quietly returns. If an error occurred while stopping the server, niced.exe reports the error but still stops the server.

If you intend to use NICE/2 a lot, start the server in your STARTUP.CMD or STARTUP folder. NICE/2 takes only a fraction of OS/2 resources, so there's really no good reason against it.

After the server has been started, use either the GUI or the command line to interact with NICE/2. Lets say you want to change the priority of Netscape and make it a bit more responsive.




Utilites

NICE/2 is provided with several utilites to ease the use of NICE/2. The utlities provided are not part of the core NICE/2 build tree and don't use any of the NICE/2 API's - they can be used 'stand-alone'.

niceps.exe [-p PID] - use this utility to report process and thread information. When invoked without switches, niceps.exe reports the list of currenlty running processes in the system. When used with the '-p' switch, niceps.exe reports thread information for the specified process.

nicex.exe -c CLASS -d DELTA COMMAND [...] - use this utility to start a process in a certain priority. CLASS and DELTA values are the same as the nice.exe command.




SDK for C/C++ and REXX

NICE/2 is provided with a SDK for C/C++ and REXX. Use this SDK to extend NICE/2 or integrate it with your own programs and scripts. The C/C++ SDK has been built with VisualAge C++ v3.0 but should work with EMX/GCC too. The C/C++ SDK includes head er and lib files (nice.h, nice.lib) and a sample program (sample.c, sample.mak). The C/C++ SDK includes the following functions:

NiceStatus() - see if the NICE/2 server is running

NiceSetPriority( pid, tid, class, delta ) - set the priority of a process and/or thread

NiceIOCtl( cmd, param1, param2 ) - generic way to contanct the NICE/2 server

NICE/2 also includes a REXX SDK to ease integration of NICE/2 with scripts. The NICE/2 REXX SDK is comprehansive and includes the NICE/2 REXX DLL (rxnice.dll) and two sample files (sample1.cmd, sample2.cmd). The REXX SDK includes the following functions:

RxNiceLoadFuncs() and RxNiceDropFuncs()

RxNiceStatus() - wrapper for NiceStatus

RxNiceSetPriority( pid, tid, class, delta ) - wrapper for NiceSetPriority

RxNiceIOCtl( cmd, param1, param2 ) - wrapper for NiceIOCtl

RxNicePS() - get a list of all processes and thread information

RxNiceMyPID() - returns the PID of this process




Known Problems

If you have a problem not listed here and you susspect a bug, please take a few minutes and download the debug version of NICE/2. With this version, the NICE/2 server writes a detailed log file that could help you (and me) diagnose the problem. Here is a list of known problems:

When a VDM (DOS window and Win-OS/2 window) is brought to the foreground, OS/2 alters the priority of the process back to (usualy) Regular 0.







Error Codes

Some of the errors NICE/2 returns:




0

-1

-2

-3

-4

-5

-6

-7

303

304

307

309

640

NO_ERROR

ERR_USAGE

ERR_INSTANCE

ERR_ENGINE_STARTED

ERR_ENGINE_STOPPED

ERR_WINSETHOOK

ERR_NOT_PM_PROCESS

ERR_HWND_NOT_FOUND

ERROR_INVALID_PROCID

ERROR_INVALID_PDELTA

ERROR_INVALID_PCLASS

ERROR_INVALID_THREADID

ERROR_TIMEOUT

no error

check swithces

niced.exe already running

NICE/2 server already running

NICE/2 server not started

internal error - please report

PID is not a PM process

internal error - please report

invalid PID ('-p')

invalid DELTA ('-d')

invalid CLASS ('-c')

invalid TID ('-t')

timeout expired