About timer in miniport driver !

Hi,
I’m write a usb driver in miniport layer , and i want to send urbs
down to low_level each 1ms time. So i try to use the timer of NDIS
“NdisMSetTimer” & “NdisMInitializeTimer” ,but DDK says “The minimum
practicable interval to specify on Windows 2000 platforms is TEN
milliseconds”. And in my test the interval is really TEN miliseconds.
So do anyone have the idea of how to send a urb downto to low_level
in 1ms periodicly . Or is there a timer which praticable interval is
1ms ?

Best regards
Josephxu .

Instead of continuously polling your device every 1 ms, you should just
pend multiple URBs (like 3) at a time. This way there will always be a
buffer in the host controller’s schedule. Also, if this is an interrupt
endpoint, just put a 1 ms internal on the endpoint and have the multiple
transfers pending. If this is a bulk endpoint, 1 ms is wishful thinking
if there is any type of contention on the usb schedule, bulk transfers
will get the lowest priority on the HC schedule.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of ze zefeng
Sent: Monday, July 18, 2005 10:58 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] About timer in miniport driver !

Hi,
I’m write a usb driver in miniport layer , and i want to send urbs
down to low_level each 1ms time. So i try to use the timer of NDIS
“NdisMSetTimer” & “NdisMInitializeTimer” ,but DDK says “The minimum
practicable interval to specify on Windows 2000 platforms is TEN
milliseconds”. And in my test the interval is really TEN miliseconds.
So do anyone have the idea of how to send a urb downto to low_level
in 1ms periodicly . Or is there a timer which praticable interval is
1ms ?

Best regards
Josephxu .


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

Yes ,this is a bulk endpoint. I need to get the clients data each 1ms
, so I have to polling my device ervery 1ms.
I use the function “ExSetTimerResolution()” to change the system timer
solution from ~10ms to ~1ms . But in this way , some OUT packets in
my loopback test can’t be sent to low level , which i observed on usb
sniffer . confused !
Whether the high frequence of sending URBs will make the OUT packets lost ?

2005/7/19, Doron Holan :
> Instead of continuously polling your device every 1 ms, you should just
> pend multiple URBs (like 3) at a time. This way there will always be a
> buffer in the host controller’s schedule. Also, if this is an interrupt
> endpoint, just put a 1 ms internal on the endpoint and have the multiple
> transfers pending. If this is a bulk endpoint, 1 ms is wishful thinking
> if there is any type of contention on the usb schedule, bulk transfers
> will get the lowest priority on the HC schedule.
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of ze zefeng
> Sent: Monday, July 18, 2005 10:58 PM
> To: Windows System Software Devs Interest List
> Subject: [ntdev] About timer in miniport driver !
>
> Hi,
> I’m write a usb driver in miniport layer , and i want to send urbs
> down to low_level each 1ms time. So i try to use the timer of NDIS
> “NdisMSetTimer” & “NdisMInitializeTimer” ,but DDK says “The minimum
> practicable interval to specify on Windows 2000 platforms is TEN
> milliseconds”. And in my test the interval is really TEN miliseconds.
> So do anyone have the idea of how to send a urb downto to low_level
> in 1ms periodicly . Or is there a timer which praticable interval is
> 1ms ?
>
> Best regards
> Josephxu .
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument:
> ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

ze zefeng wrote:

Yes ,this is a bulk endpoint. I need to get the clients data each 1ms
, so I have to polling my device ervery 1ms.

If the device really needs to deliver data every millisecond, then it
was a huge design mistake to use a bulk pipe. That’s exactly what
isochronous pipes are for. The driver queues up a bunch of URBs, and
the USB hardware makes sure one gets handled during every frame.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Yes , we will change the pipe type to isochrounou. But now we just
have the bulk hardware on the client(device), so we use bulk pipe to
check other part codes :slight_smile:
And the last question: I use timer to send one URB each 1ms , does
it will affects the OUT packets ? I observed some OUT packets can’t be
send down to low level . Does anyone have some idea of it ?

2005/7/20, Tim Roberts :
> ze zefeng wrote:
>
> >Yes ,this is a bulk endpoint. I need to get the clients data each 1ms
> >, so I have to polling my device ervery 1ms.
> >
> >
>
> If the device really needs to deliver data every millisecond, then it
> was a huge design mistake to use a bulk pipe. That’s exactly what
> isochronous pipes are for. The driver queues up a bunch of URBs, and
> the USB hardware makes sure one gets handled during every frame.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

You cannot. Windows has no mechanisms or firing any software events with
such a timeframe. Use some other logic, like interrupt pipes (they are polled
by the controller hardware) or so.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “ze zefeng”
To: “Windows System Software Devs Interest List”
Sent: Tuesday, July 19, 2005 9:58 AM
Subject: [ntdev] About timer in miniport driver !

Hi,
I’m write a usb driver in miniport layer , and i want to send urbs
down to low_level each 1ms time. So i try to use the timer of NDIS
“NdisMSetTimer” & “NdisMInitializeTimer” ,but DDK says “The minimum
practicable interval to specify on Windows 2000 platforms is TEN
milliseconds”. And in my test the interval is really TEN miliseconds.
So do anyone have the idea of how to send a urb downto to low_level
in 1ms periodicly . Or is there a timer which praticable interval is
1ms ?

Best regards
Josephxu .


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: unknown lmsubst tag argument: ‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

>Yes ,this is a bulk endpoint. I need to get the clients data each 1ms

, so I have to polling my device ervery 1ms.

Use interrupt or isoch endpoint instead. Bulk endpoints provide no such
guarantee, Windows or no Windows.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

ze zefeng wrote:

Yes , we will change the pipe type to isochrounou. But now we just
have the bulk hardware on the client(device), so we use bulk pipe to
check other part codes :slight_smile:
And the last question: I use timer to send one URB each 1ms , does
it will affects the OUT packets ? I observed some OUT packets can’t be
send down to low level . Does anyone have some idea of it ?

If there is no output URB queued up by the time a frame starts, no OUT
packet will be sent during that frame.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for your help :slight_smile:
Yes ,I have checked my codes .Sometimes ,there are really not OUT URB
be sent down low level. so ,no OUT pakcets.
The cause is that : some pakctes can’t be sent from IM to miniport
when I use a timer ( interval is 1ms) to send IN URB in MINIPORT.
But when I used a thread to polling sending IN URB , the packets can
be sent to MINIPORT successfully. Because the THREAD will be affected
by other application , so I can’t choice it .
So the questions : Do the timer will affect MINIPORT send packets to
IM ??? How can I avoid it ?
Any idea is welcome :slight_smile:

2005/7/21, Tim Roberts :
> ze zefeng wrote:
>
> > Yes , we will change the pipe type to isochrounou. But now we just
> >have the bulk hardware on the client(device), so we use bulk pipe to
> >check other part codes :slight_smile:
> > And the last question: I use timer to send one URB each 1ms , does
> >it will affects the OUT packets ? I observed some OUT packets can’t be
> >send down to low level . Does anyone have some idea of it ?
> >
> >
>
> If there is no output URB queued up by the time a frame starts, no OUT
> packet will be sent during that frame.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>

ze zefeng wrote:

Thanks for your help :slight_smile:
Yes ,I have checked my codes .Sometimes ,there are really not OUT URB
be sent down low level. so ,no OUT pakcets.
The cause is that : some pakctes can’t be sent from IM to miniport
when I use a timer ( interval is 1ms) to send IN URB in MINIPORT.
But when I used a thread to polling sending IN URB , the packets can
be sent to MINIPORT successfully. Because the THREAD will be affected
by other application , so I can’t choice it .
So the questions : Do the timer will affect MINIPORT send packets to
IM ??? How can I avoid it ?

I’m sorry, I got lost in that explanation. Software timers are
unreliable; you will never be able to use a software timer to align
yourself with the USB hardware clock.

When you say “the thread will be affected by other applications”, what
do you mean? You can certainly bump up the priority of your kernel
thread so that it runs before user threads.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thans for your helps all :slight_smile:
to :Tim Roberts
I have relove the problem , as you have said , I setted the priority
of your kernel
thread to 16(LOW_REALTIME_PRIORITY) . It runs ok .
And the root cause of why when shut the power of usb , the PC will
halt is that :
After I have setted setted the priority of your kernel thread to
16(LOW_REALTIME_PRIORITY) , when usb lost power , the thread will do
a infinite loop, and the loop control flag is setted in
“MINIPORTHALT”. So “MINIPORTHALT” will have no chance to run . Then PC
halts.
My solution is : when detect usb power down ,call “NdisMsleep()” to
wait 1ms , give “MINIPORTHALT” to run .

Thanks all again .

2005/7/22, Tim Roberts :
> ze zefeng wrote:
>
> >Thanks for your help :slight_smile:
> >Yes ,I have checked my codes .Sometimes ,there are really not OUT URB
> >be sent down low level. so ,no OUT pakcets.
> >The cause is that : some pakctes can’t be sent from IM to miniport
> >when I use a timer ( interval is 1ms) to send IN URB in MINIPORT.
> >But when I used a thread to polling sending IN URB , the packets can
> >be sent to MINIPORT successfully. Because the THREAD will be affected
> >by other application , so I can’t choice it .
> >So the questions : Do the timer will affect MINIPORT send packets to
> >IM ??? How can I avoid it ?
> >
>
> I’m sorry, I got lost in that explanation. Software timers are
> unreliable; you will never be able to use a software timer to align
> yourself with the USB hardware clock.
>
> When you say “the thread will be affected by other applications”, what
> do you mean? You can certainly bump up the priority of your kernel
> thread so that it runs before user threads.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@gmail.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>