This sample displays instance names, process identifiers, CPU-time as a percentage, high and low thresholds of the CPU-time, and the process priorities of instances of Microsoft® SQL Server™ 2000 running on the local computer. The sample also manages process priorities and gives users the option of setting them manually.
You must install Microsoft Platform Software Development Kit (SDK) to compile and run this sample.
C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Utils\pbalance
Running the Sample
- Open pbalance.dsw in Microsoft® Visual C++® 6.0 and compile the program.
- Run pbalance.exe on your local machine. The application will display the information of the running instances.
- To set the timer interval for collecting data, select any running instance in the list box and click Set (or double click any running instance name). This displays the Change Setting dialog box. On the upper-right corner, enter the new time interval value in the edit box and then click OK.
- To set high and low CPU-time thresholds of a running instance, select the running instance in the list box and click Set (or double click any running instance name). This displays the Change Setting dialog box. Enter the new high and low CPU-time thresholds values in the edit boxes. You can also set the process priority of the running instance here. To do this, select the new process priority in the combo box. Click OK to make the new settings effective.
The sample extracts the CPU real time (the percentage) consumed by each running instance once in every fixed time interval. The default value of this time interval is 5 seconds. Users have the option to set this time interval to a different value. If the CPU-time consumed by a running instance is higher than the high threshold or lower than the low threshold, the application then lowers or raises the process priority by one level. If the priority is already at the top or bottom level and cannot be lowered or raised, the priority will then remain the same. Users also have the option to set the high and low thresholds.