PsCreateSystemThread under win98

Dear Sirs
I get a problem in usb driver.Pls help me…
This thread totally stops win98 about 10 seconds(step by step).
even there are no read /write requests.just check the irp queue.

but It is good on win2000.
I can’t figure out why?



when i try to create a thread to polling overlapped io tasks in my queue in
adddevice, PsCreateSystemThread is used like below:

if (pdx->NonWINXP){
ntStatus=PsCreateSystemThread(&hThread,
THREAD_ALL_ACCESS,
NULL,
NULL,
NULL,
(PKSTART_ROUTINE)RWThreadProc,
pdx);
}else{
InitializeObjectAttributes(&oa,
NULL,
OBJ_KERNEL_HANDLE,
NULL,
NULL);
ntStatus=PsCreateSystemThread(&hThread,
THREAD_ALL_ACCESS,
&oa,
NULL,
NULL,
(PKSTART_ROUTINE)RWThreadProc,
pdx);
}

and my RWThreadProc almost do nothing because there is no any read/write
request yet.

void RWThreadProc(PDEVICE_EXTENSION pdx)
{
//some veriable defined here

WaitTimeZero=RtlConvertLongToLargeInteger(100);

//while the stop event never been signaled
while (STATUS_TIMEOUT
==KeWaitForSingleObject(&pdx->RWThreadStopEvent,
Executive,
KernelMode,
FALSE,
&WaitTimeZero))
{

KeAcquireSpinLock(&deviceExtension->RWSpin_Lock,&oldIrql);

BaseIRPEntry=ExInterlockedRemoveHeadList(&deviceExtension->RWBaseIrpListHead
,

&deviceExtension->RWListSpin);
irpEntry
=ExInterlockedRemoveHeadList(&deviceExtension->RWIrpListHead,

&deviceExtension->RWListSpin);

KeReleaseSpinLock(&deviceExtension->RWSpin_Lock,oldIrql);
if (BaseIRPEntry!=NULL && irpEntry !=NULL){
// pass the irp down
} else {
// do nothing
}
}
}

Try making your timeout negative. Presumably you want to wait for 10 us
from the time you call WaitForSingleObject, not for 10us after the
system booted (which has already passed, thus the timer will fire
immediately every time)

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of polybear
Sent: Wednesday, October 06, 2004 11:06 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] PsCreateSystemThread under win98

Dear Sirs
I get a problem in usb driver.Pls help me…
This thread totally stops win98 about 10 seconds(step by step).
even there are no read /write requests.just check the irp queue.

but It is good on win2000.
I can’t figure out why?


>
>
>
> when i try to create a thread to polling overlapped io tasks
> in my queue in adddevice, PsCreateSystemThread is used like below:
>
> if (pdx->NonWINXP){
> ntStatus=PsCreateSystemThread(&hThread,
> THREAD_ALL_ACCESS,
> NULL,
> NULL,
> NULL,
> (PKSTART_ROUTINE)RWThreadProc,
> pdx);
> }else{
> InitializeObjectAttributes(&oa,
> NULL,
> OBJ_KERNEL_HANDLE,
> NULL,
> NULL);
> ntStatus=PsCreateSystemThread(&hThread,
> THREAD_ALL_ACCESS,
> &oa,
> NULL,
> NULL,
> (PKSTART_ROUTINE)RWThreadProc,
> pdx);
> }
>
>
> and my RWThreadProc almost do nothing because there is no any
> read/write request yet.
>
> void RWThreadProc(PDEVICE_EXTENSION pdx) {
> //some veriable defined here
>
> WaitTimeZero=RtlConvertLongToLargeInteger(100);
>
> //while the stop event never been signaled
> while (STATUS_TIMEOUT
> ==KeWaitForSingleObject(&pdx->RWThreadStopEvent,
> Executive,
> KernelMode,
> FALSE,
> &WaitTimeZero))
> {
>
>
> KeAcquireSpinLock(&deviceExtension->RWSpin_Lock,&oldIrql);
>
>
> BaseIRPEntry=ExInterlockedRemoveHeadList(&deviceExtension->RWB
> aseIrpListHead
> ,
>
> &deviceExtension->RWListSpin);
> irpEntry
> =ExInterlockedRemoveHeadList(&deviceExtension->RWIrpListHead,
>
> &deviceExtension->RWListSpin);
>
>
> KeReleaseSpinLock(&deviceExtension->RWSpin_Lock,oldIrql);
> if (BaseIRPEntry!=NULL &&
> irpEntry !=NULL){
> // pass the irp down
> } else {
> // do nothing
> }
> }
> }
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as:
> xxxxx@windows.microsoft.com To unsubscribe send a blank
> email to xxxxx@lists.osr.com
>