KeDelayExecutionThread strange range problem

Hi,
I’m using this code to craete a delay
of about 300usec in passive level

delay.QuadPart = - 10*30*10;
KeDelayExecutionThread (&delay);

the delay times I get are from about ~300usec
but most of the time up to 12msec

should I use KeStallProcessor for that amount of time ?

Thanks, Tom.

Do the call with all three parameters. Having random parameters is not
good. Also check the return to see if you were waken early.

----- Original Message -----
From: “Tomer Goldberg”
To: “NT Developers Interest List”
Sent: Monday, January 06, 2003 10:10 AM
Subject: [ntdev] KeDelayExecutionThread strange range problem

>
> Hi,
> I’m using this code to craete a delay
> of about 300usec in passive level
>
> delay.QuadPart = - 103010;
> KeDelayExecutionThread (&delay);
>
> the delay times I get are from about ~300usec
> but most of the time up to 12msec
>
> should I use KeStallProcessor for that amount of time ?
>
> Thanks, Tom.
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Right I forgot the params.
(KernelMode,False,&delay)

regarding being waken early I dont think its the case

-----Original Message-----
From: David J. Craig [mailto:xxxxx@yoshimuni.com]
Sent: Monday, January 06, 2003 6:09 PM
To: NT Developers Interest List
Subject: [ntdev] Re: KeDelayExecutionThread strange range problem

Do the call with all three parameters. Having random
parameters is not
good. Also check the return to see if you were waken early.

----- Original Message -----
From: “Tomer Goldberg”
> To: “NT Developers Interest List”
> Sent: Monday, January 06, 2003 10:10 AM
> Subject: [ntdev] KeDelayExecutionThread strange range problem
>
>
> >
> > Hi,
> > I’m using this code to craete a delay
> > of about 300usec in passive level
> >
> > delay.QuadPart = - 103010;
> > KeDelayExecutionThread (&delay);
> >
> > the delay times I get are from about ~300usec
> > but most of the time up to 12msec
> >
> > should I use KeStallProcessor for that amount of time ?
> >
> > Thanks, Tom.
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@royatech.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Isn’t it true that you cannot delay ( and even set timers ) for
timeintervals beyond the
interval clock time i.e. the finest grain IS the interval clock time ? On
many systems,
this is 10 mS ( which the explains the 12 mS measured time ).

----- Original Message -----
From: “Tomer Goldberg”
To: “NT Developers Interest List”
Sent: Monday, January 06, 2003 5:56 PM
Subject: [ntdev] Re: KeDelayExecutionThread strange range problem

>
> Right I forgot the params.
> (KernelMode,False,&delay)
>
> regarding being waken early I dont think its the case
>
> > -----Original Message-----
> > From: David J. Craig [mailto:xxxxx@yoshimuni.com]
> > Sent: Monday, January 06, 2003 6:09 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: KeDelayExecutionThread strange range problem
> >
> >
> > Do the call with all three parameters. Having random
> > parameters is not
> > good. Also check the return to see if you were waken early.
> >
> > ----- Original Message -----
> > From: “Tomer Goldberg”
> > To: “NT Developers Interest List”
> > Sent: Monday, January 06, 2003 10:10 AM
> > Subject: [ntdev] KeDelayExecutionThread strange range problem
> >
> >
> > >
> > > Hi,
> > > I’m using this code to craete a delay
> > > of about 300usec in passive level
> > >
> > > delay.QuadPart = - 103010;
> > > KeDelayExecutionThread (&delay);
> > >
> > > the delay times I get are from about ~300usec
> > > but most of the time up to 12msec
> > >
> > > should I use KeStallProcessor for that amount of time ?
> > >
> > > Thanks, Tom.
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@royatech.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Look at the LARGE_INTEGER delay value just before the call and see if the
bits are correct for the entire 64-bit value. Check the return value with
an ASSERT if it is not STATUS_SUCCESS just to be sure. There are ways even
with these parameters that it can wake up. Small chance, but why leave it
to chance.

----- Original Message -----
From: “Tomer Goldberg”
To: “NT Developers Interest List”
Sent: Monday, January 06, 2003 11:56 AM
Subject: [ntdev] Re: KeDelayExecutionThread strange range problem

>
> Right I forgot the params.
> (KernelMode,False,&delay)
>
> regarding being waken early I dont think its the case
>
> > -----Original Message-----
> > From: David J. Craig [mailto:xxxxx@yoshimuni.com]
> > Sent: Monday, January 06, 2003 6:09 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: KeDelayExecutionThread strange range problem
> >
> >
> > Do the call with all three parameters. Having random
> > parameters is not
> > good. Also check the return to see if you were waken early.
> >
> > ----- Original Message -----
> > From: “Tomer Goldberg”
> > To: “NT Developers Interest List”
> > Sent: Monday, January 06, 2003 10:10 AM
> > Subject: [ntdev] KeDelayExecutionThread strange range problem
> >
> >
> > >
> > > Hi,
> > > I’m using this code to craete a delay
> > > of about 300usec in passive level
> > >
> > > delay.QuadPart = - 103010;
> > > KeDelayExecutionThread (&delay);
> > >
> > > the delay times I get are from about ~300usec
> > > but most of the time up to 12msec
> > >
> > > should I use KeStallProcessor for that amount of time ?
> > >
> > > Thanks, Tom.
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@royatech.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

To my knowledge there is no reliable means of delaying for less than a
quantum, which is usually 10 msec. The fact that you have gotten around
300usec, sometimes, indicates your threads quantum had not expired and the
kernel had not left the context of your thread, so back you came, jiggedy
jig. You MIGHT achieve what you want by raising IRQL to DISPATCH_LEVEL and
then calling KeStallExecutionProcessor in 10 usec increments.

However, if this is at anytime other than boot/initialization you will have
a lot of other pissed off driver writers looking for your head. :slight_smile:


Gary G. Little
Have Computer, Will Travel …
909-698-3191
909-551-2105

“Tomer Goldberg” wrote in message news:xxxxx@ntdev…
>
>
> Hi,
> I’m using this code to craete a delay
> of about 300usec in passive level
>
> delay.QuadPart = - 103010;
> KeDelayExecutionThread (&delay);
>
> the delay times I get are from about ~300usec
> but most of the time up to 12msec
>
> should I use KeStallProcessor for that amount of time ?
>
> Thanks, Tom.
>
>
>

Gary is right. You could change the quantum ( clock time ) by means of
“ExSetTimerResolution(…)” to up to
1 msec. This is action does change the quantum however for all drivers, and
this would change the behaveour
of drivers that made the same faulty assumption about timer-values ( the
“serial” sample is one of them … ).

MS should urgently mention this within their documentation of KeSetTimer,
KeDelayExecutionThread, … ! !

----- Original Message -----
From: “Tomer Goldberg”
To: “NT Developers Interest List”
Sent: Monday, January 06, 2003 4:10 PM
Subject: [ntdev] KeDelayExecutionThread strange range problem

>
> Hi,
> I’m using this code to craete a delay
> of about 300usec in passive level
>
> delay.QuadPart = - 103010;
> KeDelayExecutionThread (&delay);
>
> the delay times I get are from about ~300usec
> but most of the time up to 12msec
>
> should I use KeStallProcessor for that amount of time ?
>
> Thanks, Tom.
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@compaqnet.be
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

Look at the FLPYDISK.C file and it uses a delay of 900.

----- Original Message -----
From: “Gary G. Little”
Newsgroups: ntdev
To: “NT Developers Interest List”
Sent: Monday, January 06, 2003 1:37 PM
Subject: [ntdev] Re: KeDelayExecutionThread strange range problem

> To my knowledge there is no reliable means of delaying for less than a
> quantum, which is usually 10 msec. The fact that you have gotten around
> 300usec, sometimes, indicates your threads quantum had not expired and the
> kernel had not left the context of your thread, so back you came, jiggedy
> jig. You MIGHT achieve what you want by raising IRQL to DISPATCH_LEVEL and
> then calling KeStallExecutionProcessor in 10 usec increments.
>
> However, if this is at anytime other than boot/initialization you will
have
> a lot of other pissed off driver writers looking for your head. :slight_smile:
>
> –
> Gary G. Little
> Have Computer, Will Travel …
> 909-698-3191
> 909-551-2105
>
> “Tomer Goldberg” wrote in message news:xxxxx@ntdev…
> >
> >
> > Hi,
> > I’m using this code to craete a delay
> > of about 300usec in passive level
> >
> > delay.QuadPart = - 103010;
> > KeDelayExecutionThread (&delay);
> >
> > the delay times I get are from about ~300usec
> > but most of the time up to 12msec
> >
> > should I use KeStallProcessor for that amount of time ?
> >
> > Thanks, Tom.
> >
> >
> >
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

well the quantum issue makes sense since its
the scheduler job to take your thread out
of context with KeDelay…

than why is the function parameter
is in 100nsec resolution ?

what about :
for(i=0;…
KeStallExec…(50) ;

in passive level (not more than 50 as the ddk states) ?

-----Original Message-----
From: David J. Craig [mailto:xxxxx@yoshimuni.com]
Sent: Monday, January 06, 2003 10:59 PM
To: NT Developers Interest List
Subject: [ntdev] Re: KeDelayExecutionThread strange range problem

Look at the FLPYDISK.C file and it uses a delay of 900.

----- Original Message -----
From: “Gary G. Little”
> Newsgroups: ntdev
> To: “NT Developers Interest List”
> Sent: Monday, January 06, 2003 1:37 PM
> Subject: [ntdev] Re: KeDelayExecutionThread strange range problem
>
>
> > To my knowledge there is no reliable means of delaying for
> less than a
> > quantum, which is usually 10 msec. The fact that you have
> gotten around
> > 300usec, sometimes, indicates your threads quantum had not
> expired and the
> > kernel had not left the context of your thread, so back you
> came, jiggedy
> > jig. You MIGHT achieve what you want by raising IRQL to
> DISPATCH_LEVEL and
> > then calling KeStallExecutionProcessor in 10 usec increments.
> >
> > However, if this is at anytime other than
> boot/initialization you will
> have
> > a lot of other pissed off driver writers looking for your head. :slight_smile:
> >
> > –
> > Gary G. Little
> > Have Computer, Will Travel …
> > 909-698-3191
> > 909-551-2105
> >
> > “Tomer Goldberg” wrote in message
> news:xxxxx@ntdev…
> > >
> > >
> > > Hi,
> > > I’m using this code to craete a delay
> > > of about 300usec in passive level
> > >
> > > delay.QuadPart = - 103010;
> > > KeDelayExecutionThread (&delay);
> > >
> > > the delay times I get are from about ~300usec
> > > but most of the time up to 12msec
> > >
> > > should I use KeStallProcessor for that amount of time ?
> > >
> > > Thanks, Tom.
> > >
> > >
> > >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@royatech.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

To give you fine granularity when you need timing information, but not as a
delay period.

Your loop will count down a m in of 300 usecs but there is no way to
guarantee ONLY 300 usecs. If your quantum expires on iteration 4, you will
have a 10 msec lump between 4 and 5 … Not even raising IRQL to
DISPATCH_LEVEL will guarantee it. You might try HIGH_LEVEL, but be sure to
hide because for sure you are going to screw up someone’s timing.


Gary G. Little
Have Computer, Will Travel …
909-698-3191
909-551-2105

“Tomer Goldberg” wrote in message news:xxxxx@ntdev…
>
>
> well the quantum issue makes sense since its
> the scheduler job to take your thread out
> of context with KeDelay…
>
> than why is the function parameter
> is in 100nsec resolution ?
>
> what about :
> for(i=0;…
> KeStallExec…(50) ;
>
> in passive level (not more than 50 as the ddk states) ?
>
> > -----Original Message-----
> > From: David J. Craig [mailto:xxxxx@yoshimuni.com]
> > Sent: Monday, January 06, 2003 10:59 PM
> > To: NT Developers Interest List
> > Subject: [ntdev] Re: KeDelayExecutionThread strange range problem
> >
> >
> > Look at the FLPYDISK.C file and it uses a delay of 900.
> >
> > ----- Original Message -----
> > From: “Gary G. Little”
> > Newsgroups: ntdev
> > To: “NT Developers Interest List”
> > Sent: Monday, January 06, 2003 1:37 PM
> > Subject: [ntdev] Re: KeDelayExecutionThread strange range problem
> >
> >
> > > To my knowledge there is no reliable means of delaying for
> > less than a
> > > quantum, which is usually 10 msec. The fact that you have
> > gotten around
> > > 300usec, sometimes, indicates your threads quantum had not
> > expired and the
> > > kernel had not left the context of your thread, so back you
> > came, jiggedy
> > > jig. You MIGHT achieve what you want by raising IRQL to
> > DISPATCH_LEVEL and
> > > then calling KeStallExecutionProcessor in 10 usec increments.
> > >
> > > However, if this is at anytime other than
> > boot/initialization you will
> > have
> > > a lot of other pissed off driver writers looking for your head. :slight_smile:
> > >
> > > –
> > > Gary G. Little
> > > Have Computer, Will Travel …
> > > 909-698-3191
> > > 909-551-2105
> > >
> > > “Tomer Goldberg” wrote in message
> > news:xxxxx@ntdev…
> > > >
> > > >
> > > > Hi,
> > > > I’m using this code to craete a delay
> > > > of about 300usec in passive level
> > > >
> > > > delay.QuadPart = - 103010;
> > > > KeDelayExecutionThread (&delay);
> > > >
> > > > the delay times I get are from about ~300usec
> > > > but most of the time up to 12msec
> > > >
> > > > should I use KeStallProcessor for that amount of time ?
> > > >
> > > > Thanks, Tom.
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > > —
> > > You are currently subscribed to ntdev as: xxxxx@yoshimuni.com
> > > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
> >
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@royatech.com
> > To unsubscribe send a blank email to xxxxx@lists.osr.com
> >
>
>
>

Doing something like:

for i=0 to approximately 6
{
RaiseIrql
KeStallExecutionProcessor(50);
LowerIrql
}

at passive level will give a chance to scheduled DPCs to be run.
(GOOD)

Doing:
RaiseIrql
KeStallExecutionProcessor(300);
LowerIrql

will lock out all others for too long. (BAD)

ISRs will prolong your interval anyway, so I hope you do not need
exactly 300usec delay, but something not much longer than 300usec.

Hmm, I wonder how much time RaiseIrql/LowerIrql will take at each
call?
'approximately 6' means accounting the overhead of function calls.

Norbert.

"He was so narrow-minded he could see through a keyhole with both
eyes."
---- snip ----

> > > jig. You MIGHT achieve what you want by raising IRQL to
> > DISPATCH_LEVEL and
> > > then calling KeStallExecutionProcessor in 10 usec increments.
> > >
---- snip ----