#include "test.h"
#include <windows.h>
volatile long m = 0;
HANDLE *eventH;
DWORD __stdcall fun(void *p)
{
Sleep(1000);
while(InterlockedExchange(&m, 1) != 0)
{
Sleep(0);
}
cout << *(int*)p << endl;
m = 0;
SetEvent(eventH[*(int*)p]);
return 0;
}
int main()
{
const unsigned int num = 64;
DWORD threadid[num];
HANDLE h[num];
eventH = new HANDLE[num];
unsigned int buffer[num];
for (int i = 0; i < num; ++i)
{
eventH[i] = CreateEvent(NULL, false, 0, NULL);
buffer[i] = i;
h[i] = CreateThread(NULL, 0, fun, &buffer[i], 0, &threadid[i]);
}
WaitForMultipleObjects(num, eventH, true, INFINITE);
WaitForMultipleObjects(num, h, true, INFINITE);
return 0;
}
Wednesday, November 17, 2010
Tuesday, June 29, 2010
Is it better to buy or rent a house?
Personally I found this calculator very useful.
Don't forget to set the appreciation rate for house price and price rent....
Try it:
http://www.itrust.in/tools-and-calculators/Buy-vs-Rent/Calculator.jsp
Enjoy !!
Don't forget to set the appreciation rate for house price and price rent....
Try it:
http://www.itrust.in/tools-and-calculators/Buy-vs-Rent/Calculator.jsp
Enjoy !!
Wednesday, June 23, 2010
Is your disk showing less space ?
If Hybernate is on in your m/c, then a hidden file will be created equal to the size of your RAM. so you will loose that much space from your avilable disk space. In case you want to increase disk size, you have to disable Hybernate.
Command:
Disable command : powercfg /hibernate off
Enable command : powercfg /hibernate on
PS: Tested on my windows 2k8 m/c
Command:
Disable command : powercfg /hibernate off
Enable command : powercfg /hibernate on
PS: Tested on my windows 2k8 m/c
Tuesday, May 4, 2010
Tuesday, April 6, 2010
Run command prompt from system account
Normally process run with account which is currenlty logged in and Services run in System account.
so the idea is to create a service which will launch "Command prompt". This idea is valid to launch any application in System account.
This is the command to create such a servcie: (type this on command prompt)
sc create testservice binpath= "cmd /k start" type= own type= interact
please remember that there is no space before '=' and one space after '='. I dont know why but it is required.
This command will install the service, now go to services.msc and start this new service. one error will come but still you will be able to see a cmd.exe running in system account :)
so the idea is to create a service which will launch "Command prompt". This idea is valid to launch any application in System account.
This is the command to create such a servcie: (type this on command prompt)
sc create testservice binpath= "cmd /k start" type= own type= interact
please remember that there is no space before '=' and one space after '='. I dont know why but it is required.
This command will install the service, now go to services.msc and start this new service. one error will come but still you will be able to see a cmd.exe running in system account :)
Subscribe to:
Posts (Atom)