home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / PRIORITY.LZH / PRIORITY.C next >
C/C++ Source or Header  |  1992-07-11  |  1KB  |  49 lines

  1. #define INCL_DOS
  2.  
  3. #include <os2.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <process.h>
  8.  
  9.  
  10. /* quickie program to adjust priority of a program being spawned */
  11.  
  12.  
  13. int main (int argc,char *argv[]) {
  14.  
  15.   int priclass,pridelta;
  16.   struct {
  17.     int pid;
  18.     int thread;
  19.     int parentpid;
  20.   } pid;
  21.  
  22.   if(argc < 4) {
  23.     printf("\nUsage:  Priority.exe <priclass> <pridelta> program args...\n\n"
  24.            " <priclass>:  1-4\n"
  25.            "    1 = idle    2 = normal    3 = high    4 = fixed high (lower than 3)\n"
  26.            " <pridelta>:  0-31\n"
  27.            "    the higher the number, the higher the priority\n");
  28.     exit(1);
  29.   }
  30.  
  31.   priclass = atoi(argv[1]);
  32.   pridelta = atoi(argv[2]);
  33.  
  34.   if(priclass < 1 || priclass > 4) {
  35.     printf("\nInvalid priority class (first arg) %d\n",priclass);
  36.     exit(1);
  37.   }
  38.  
  39.   DosGetPID (&pid);
  40.   if (!DosSetPrty (2, priclass, pridelta, pid.thread)) {
  41.     printf("\nPriority set to %d,%d\n", priclass, pridelta);
  42.   }
  43.   else {
  44.     printf("\n\07Couldn't affect priority\n");
  45.   }
  46.  
  47.   return spawnvp(P_WAIT,argv[3],&argv[3]);
  48. }
  49.