Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Vista Drivers > interrupts

Reply
 
 
codeFather
Guest
Posts: n/a

 
      06-17-2010
the following code stops the interrupts on the both the processors , but
nothing happens, i am able use the mouse and keyboard as usual (was expecting
a reboot or bsod :S) whats going on here?

#include "ntddk.h"
#include <windef.h>

int i;
HANDLE thrHwnd;
KEVENT syncEvent;
BOOL processors[16];
int totalProcessors,processorsMarked;

void displayCpuName()
{
if (processors[KeGetCurrentProcessorNumber()]==TRUE)
{
DbgPrint("The Processor %d, ran the code
before!!",KeGetCurrentProcessorNumber());
KeSetEvent(&syncEvent,0,FALSE);
PsTerminateSystemThread(0);
return;
}
else
{
DbgPrint("The Processor %d, is running the code for the first
time",KeGetCurrentProcessorNumber());
__asm{
cli
}
processors[KeGetCurrentProcessorNumber()]=TRUE;
processorsMarked++;
KeSetEvent(&syncEvent,0,FALSE);
PsTerminateSystemThread(0);
return;
}
}

NTSTATUS onUnload (IN PDRIVER_OBJECT driverObject)
{
DbgPrint("Driver Unloaded Successfully");
return STATUS_SUCCESS;
}

NTSTATUS DriverEntry (IN PDRIVER_OBJECT driverObject, IN PUNICODE_STRING
registryPath)
{
DbgPrint("Driver Loaded Successfully");
driverObject->DriverUnload = onUnload;

processorsMarked = 0;
for(i = 0; i < 16;i++)
processors[i] = FALSE;
totalProcessors = KeNumberProcessors;

KeInitializeEvent(&syncEvent,SynchronizationEvent, FALSE);
while(TRUE)
{
PsCreateSystemThread(&thrHwnd,(ACCESS_MASK)
0L,NULL,NULL,NULL,(PKSTART_ROUTINE) displayCpuName,NULL);
KeWaitForSingleObject(&syncEvent,Executive,KernelM ode,FALSE,NULL);
if(processorsMarked == totalProcessors) break;
}
return STATUS_SUCCESS;
}

thanks!
 
Reply With Quote
 
 
 
 
SdB
Guest
Posts: n/a

 
      06-17-2010
You may want to run a thread on a dedicated cpu core by setting the thread
affinity.
KeGetCurrentProcessorNumber() might return not the correct number as your
thread is running at passive level. That would be something to consider.

-Stefan

"codeFather" wrote:

> the following code stops the interrupts on the both the processors , but
> nothing happens, i am able use the mouse and keyboard as usual (was expecting
> a reboot or bsod :S) whats going on here?
>
> #include "ntddk.h"
> #include <windef.h>
>
> int i;
> HANDLE thrHwnd;
> KEVENT syncEvent;
> BOOL processors[16];
> int totalProcessors,processorsMarked;
>
> void displayCpuName()
> {
> if (processors[KeGetCurrentProcessorNumber()]==TRUE)
> {
> DbgPrint("The Processor %d, ran the code
> before!!",KeGetCurrentProcessorNumber());
> KeSetEvent(&syncEvent,0,FALSE);
> PsTerminateSystemThread(0);
> return;
> }
> else
> {
> DbgPrint("The Processor %d, is running the code for the first
> time",KeGetCurrentProcessorNumber());
> __asm{
> cli
> }
> processors[KeGetCurrentProcessorNumber()]=TRUE;
> processorsMarked++;
> KeSetEvent(&syncEvent,0,FALSE);
> PsTerminateSystemThread(0);
> return;
> }
> }
>
> NTSTATUS onUnload (IN PDRIVER_OBJECT driverObject)
> {
> DbgPrint("Driver Unloaded Successfully");
> return STATUS_SUCCESS;
> }
>
> NTSTATUS DriverEntry (IN PDRIVER_OBJECT driverObject, IN PUNICODE_STRING
> registryPath)
> {
> DbgPrint("Driver Loaded Successfully");
> driverObject->DriverUnload = onUnload;
>
> processorsMarked = 0;
> for(i = 0; i < 16;i++)
> processors[i] = FALSE;
> totalProcessors = KeNumberProcessors;
>
> KeInitializeEvent(&syncEvent,SynchronizationEvent, FALSE);
> while(TRUE)
> {
> PsCreateSystemThread(&thrHwnd,(ACCESS_MASK)
> 0L,NULL,NULL,NULL,(PKSTART_ROUTINE) displayCpuName,NULL);
> KeWaitForSingleObject(&syncEvent,Executive,KernelM ode,FALSE,NULL);
> if(processorsMarked == totalProcessors) break;
> }
> return STATUS_SUCCESS;
> }
>
> thanks!

 
Reply With Quote
 
Pavel A.
Guest
Posts: n/a

 
      06-18-2010
"codeFather" <> wrote in message
news:EDADDFA3-B24D-4650-B4C1-...
> the following code stops the interrupts on the both the processors , but
> nothing happens, i am able use the mouse and keyboard as usual (was
> expecting
> a reboot or bsod :S) whats going on here?


Whenever you call some system function, it can enable interrupts again.
Cli is not a blessed way to disable local interrupts in NT.

--pa


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IoConnectInterrupt - STATUS_INVALID_PARAMETER Mohit Gupta Windows Vista Drivers 7 06-16-2010 01:48 PM
Re: ActiveSync seems conficting to Drivers containing interrupts. Paul G. Tobey [eMVP] ActiveSync 0 12-16-2008 02:46 PM
wireless causing excessive hardware interrupts dcp12345678@gmail.com Windows Vista Performance 1 11-24-2007 11:02 AM
Drivers..is it really that hard?? Puppy Breath Windows Vista Hardware 27 03-12-2007 01:39 PM
Re: High Hardware Interrupts Rick Rogers Windows Vista Hardware 0 12-14-2006 01:12 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59