Changing Thread Priority w/Apache
| From: | Scott Dial | Date: | Fri, 27 Jul 2001 07:51:32 +0000 |
| Subject: | Changing Thread Priority w/Apache | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-8527@lists.php.net to get a copy of this message | ||
I have a process intensive script that my friends use of my computer. The
problem is that it eats my cycles and I want to make sure my threads get
priority. I don't see any way to change this in apache. So, I decided to
make a wrapper for php.exe that would spawn it and change the priority.
Anyone have any ideas why apache throws me a Error 500 now. Here is my
program:
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int nCmdShow)
{
STARTUPINFO phpSI;
PROCESS_INFORMATION phpPI;
BOOL bResult;
memset(&phpSI, 0, sizeof(STARTUPINFO));
phpSI.cb = sizeof(STARTUPINFO);
phpSI.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
phpSI.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
phpSI.hStdError = GetStdHandle(STD_ERROR_HANDLE);
phpSI.dwFlags = STARTF_USESTDHANDLES; //Use the handles above
bResult = CreateProcess(
"php.exe",
lpCmdLine,
NULL,
NULL,
FALSE,
IDLE_PRIORITY_CLASS,
NULL, // Inherit this process's enviroment
NULL,
&phpSI,
&phpPI);
if(bResult)
SetThreadPriority(phpPI.hThread, THREAD_PRIORITY_BELOW_NORMAL); //Set
priority
return bResult;
}
--
Scott "Wrath" Dial
wrath@calc.org
ICQ#3608935
Member of TCPA - tcpa.calc.org
PGP key available