KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Changing program priority with the OS X terminal
PRODUCT: 4D | VERSION: | PLATFORM: Mac OS X
Published On: November 27, 2002

Compatibility: OS X native applications
Platforms: Mac OS X

Running applications can be reprioritized from the OS X Terminal with the renice command. Renice is a handy way to speed up programs in certain cases. Before running renice, first make sure the application you want to reprioritize is running, then find its process ID, using either the graphical Process Viewer utility or the Terminal command top. Here is a partial listing of the output from top on a system running 4D Server:

[Merops:~] apiaster% top

Processes: 43 total, 4 running, 39 sleeping... 131 threads 09:24:04
Load Avg: 1.54, 1.14, 0.95 CPU usage: 75.4% user, 24.6% sys, 0.0% idle
SharedLibs: num = 102, resident = 21.4M code, 2.07M data, 8.03M LinkEdit
MemRegions: num = 4445, resident = 111M + 6.02M private, 81.5M shared
PhysMem: 56.2M wired, 213M active, 165M inactive, 434M used, 78.5M free
VM: 3.18G + 61.0M 32555(0) pageins, 50871(0) pageouts

PID COMMAND %CPU TIME #TH #PRTS #MREGS RPRVT RSHRD RSIZE VSIZE
2329 BBEdit 6.5 0.0% 0:02.60 4 88 180 3.81M 13.0M 18.1M- 83.8M
2328 top 9.3% 0:04.73 1 14 17 244K 340K 540K 13.6M
2321 tcsh 0.0% 0:00.07 1 10 16 340K 676K 796K 5.73M
2318 4D Server 3.6% 0:10.38 4 85 210 8.56M 20.3M 24.2M 101M
2288 lookupd 0.0% 0:00.46 2 33 45 332K 512K 864K 14.9M
1743 DirectoryS 0.0% 0:01.69 3 76 126 648K 2.74M 3.11M 20.9M
1737 Finder 0.0% 1:57.47 4 113 294 6.61M 31.8M 26.2M 127M
1549 Terminal 78.7% 1:15.53 5 94 288 2.79M+ 9.91M 17.6M+ 75.6M+
1242 TruBlueEnv 2.1% 65:23.68 18 194 267 17.4M 7.16M 17.8M 1.07G


4D Server's process ID is 2318 in this example. The process ID is almost certain to be different the next time 4D Server is launched. Press q to quit top and you're ready to run renice. Renice requires administrative privileges to run and is commonly called through the sudo command:

[Merops:~] apiaster% sudo renice -5 2318
Password:
2318: old priority 0, new priority -5
The arguments used with renice in this example are a priority code of -5 (high priority) and 2418 (4D Server's process ID). The priority code values range from -20 (highest) to 20 (lowest). Remember to use negative values for higher priorities, even though it is counter-intuitive.



Giving one program a higher priority reduces the time available to other processes. Since a program like 4D Server depends on other OS processes, experiment with different priority settings to obtain the effect you want.

Note: Renice works on OS level processes. All programs running in the Classic environment share a single process and cannot be manipulated individually by renice.

Complete documentation about sudo, top, and renice can be found within Terminal using the man command. For example,

[Merops:~] apiaster% man renice