View Single Post
Old May 20th, 2006, 4:27 AM   #4
grumpy
Programming Guru
 
grumpy's Avatar
 
Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,253
Rep Power: 5 grumpy will become famous soon enough
Quote:
Originally Posted by coder0xff
The purpose is to allow the user to suspend any arbitrary process (like if it is being a processor/disk access hog). It will also use it for throttling disk access of other programs.
I wouldn't write a program to do that: use the windows task manager to lower the priority of the offending process. Process priority is used by the windows scheduler to determine what CPU resources (in particular) are made available to each program. It is possible to do that programatically (e.g. SetPriorityClass() function for controlling priority of a process), but functionally you can't do much more than can be done with the task manager.

I would also be very cautious about the notion of suspending a disk hog: doing so might be counter productive, as I/O drivers still need to manage context of a program that is trying to access the disk but has been suspended. For example, suspending a process that has opened a file can (depending on how the file is opened) mean that file is no longer accessible to other processes. A program that is simply reading from disk can be a disk hog, and not all programs open files for read-only access in a way that allows for shared access.

I would not allow a user to arbitrarily suspend or change priority of any thread/processes (and neither does the task manager). In particular, fiddling with behaviour of processes that are necessary to system functioning can hurt system stability. There will be some processes whos priority cannot be changed (and cannot be suspended) because they are fundamental to workings of the operating system. Generally, users will not have the necessary access rights to change behaviour of system-owned processes. And allowing such access rights to your program would be a VERY poor idea.
grumpy is offline   Reply With Quote