home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 July / CHIP_CD_2004-07.iso / software / nncron_hit / files / nncron189.exe / plugins / process.spf < prev    next >
Text File  |  2003-11-27  |  2KB  |  44 lines

  1. \ File:         process.spf
  2. \ Author:       Nicholas Nemtsev
  3. \ Date:         14.06.2002
  4. \ Modified:     25.11.2003 (PROC-WAIT-CPU-USAGE)
  5. \ Description:  Process priority setting etc.
  6.  
  7. \ Usage: S" process-name" <priority-class> PRIORITY
  8. \        Priority classes: NORMAL_PRIORITY_CLASS, IDLE_PRIORITY_CLASS,
  9. \                          HIGH_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS,
  10. \                          BELOW_NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS
  11. \        S" process-name" <interval-sec> <min-usage> <max-count> PROC-WAIT-CPU-USAGE
  12.  
  13. \ Example: S" plugger.exe" HIGH_PRIORITY_CLASS PRIORITY
  14.  
  15. WINAPI: SetPriorityClass KERNEL32.DLL
  16.  
  17. 0x00000020 CONSTANT NORMAL_PRIORITY_CLASS
  18. 0x00000040 CONSTANT IDLE_PRIORITY_CLASS
  19. 0x00000080 CONSTANT HIGH_PRIORITY_CLASS
  20. 0x00000100 CONSTANT REALTIME_PRIORITY_CLASS
  21. 0x00004000 CONSTANT BELOW_NORMAL_PRIORITY_CLASS
  22. 0x00008000 CONSTANT ABOVE_NORMAL_PRIORITY_CLASS
  23.  
  24. : PRIORITY { a u p \ hproc -- }
  25.     a u PROC-EXIST? ?DUP
  26.     IF
  27.         FALSE 0x200 OpenProcess TO hproc
  28.         p hproc SetPriorityClass DROP
  29.         hproc CloseHandle DROP
  30.     THEN
  31. ;
  32.  
  33. : PROC-WAIT-CPU-USAGE { a u interval-sec threshold-usage max-count \ ms cnt -- }
  34.     threshold-usage 1 MAX 100 MIN TO threshold-usage
  35.     interval-sec 1 MAX 60 MIN 1000 * TO ms
  36.     max-count 0 MAX TO max-count
  37.     0 TO cnt
  38.     BEGIN
  39.         a u ms (PROC-CPU-USAGE) threshold-usage <
  40.         IF  cnt 1+  ELSE  0 THEN
  41.         TO cnt
  42.         cnt max-count >
  43.     UNTIL
  44. ;