In my driver I need to send a single request to two HW devices in parallel.
I’m planning on spinning two threads to do the work, while returning pending
in the original.
I was wondering if I should use a WorkItem (using IoQueueWorkItem) or create
s system thread (using PsCreateSystemThread)?
I’m asking because I’ve never used PsCreateSystemThread. I’ve used
IoQueueWorkItem for the purpose of deferring work I couldn’t do at
DISPATCH_LEVEL, but I have zero experience with adding multiple threads due
to inherent HW parallelism.
thanks,
Daniel Nemiroff
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
The system thread may be the best way to go, using an event to wake the
thread up for each hardware event you may have.
The problem you can get into with worker threads is the number of available
threads is finite, and typically they do not wait. They are queued when
needed, do what they need to do when IRQL drops below DISPATCH_LEVLEL, and
exit.
Gary G. Little
Staff Engineer
Broadband Storage, Inc.
xxxxx@broadstor.com
-----Original Message-----
From: Nemiroff, Daniel [mailto:xxxxx@intel.com]
Sent: Monday, October 29, 2001 8:23 AM
To: NT Developers Interest List
Subject: [ntdev] WorkItem or PsCreateSystemThread
In my driver I need to send a single request to two HW devices in parallel.
I’m planning on spinning two threads to do the work, while returning pending
in the original.
I was wondering if I should use a WorkItem (using IoQueueWorkItem) or create
s system thread (using PsCreateSystemThread)?
I’m asking because I’ve never used PsCreateSystemThread. I’ve used
IoQueueWorkItem for the purpose of deferring work I couldn’t do at
DISPATCH_LEVEL, but I have zero experience with adding multiple threads due
to inherent HW parallelism.
thanks,
Daniel Nemiroff
You are currently subscribed to ntdev as: xxxxx@broadstor.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
“Gary Little” wrote in message news:xxxxx@ntdev…
>
> The problem you can get into with worker threads is the number of
available
> threads is finite, and typically they do not wait.
>
I agree that spinning your own threads is probably the way to go. But not
for quite the same reasons Gary cites.
Note that in Win2K and later, the number of threads in the worker thread
pools grow and shrink dynamically to match need. So, while the number of
threads is certainly “finite” it is not fixed at a low number as it was back
in the days of NT V4.
If you have an on-going need for workers, it’s usually best to create your
own little thread pool. You never have to worry about contention in the
system worker thread pool, and you also get to control the thread
priorities. Note that in our experience, higher priorities are not
necessarily better if its parallelism that you’re looking for (consider the
“high priority worker thread” effect… you post a request to a work thread
set for a higher scheduling priority then that at which you’re running, set
the event and… bang! the worker thread runs to completion before your
main-line thread can even queue the second request or return
STATUS_PENDING).
So, yeah… as Gary advised: Roll your own.
Peter
OSR
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Hi Daniel,
Own threads cannot deadlock, exdcutive’s worker threads can. In one of my
drivers (monolithic SCSI port) I was using IoQueueWorkItem() for request
processing at PASSIVE_LEVEL, but found that in very heavy load ciondition
the driver start to work slower and slower and finally the whole system
freeze. I think that’s b/s executíve worker threads were blocked at FSD
level and my work item code was not called. Using PsCreateSystemThread()
healed this desease.
Anton
On 10/29/01, ““Nemiroff, Daniel” ” wrote:
> In my driver I need to send a single request to two HW devices in parallel.
> I’m planning on spinning two threads to do the work, while returning pending
> in the original.
> I was wondering if I should use a WorkItem (using IoQueueWorkItem) or create
> s system thread (using PsCreateSystemThread)?
> I’m asking because I’ve never used PsCreateSystemThread. I’ve used
> IoQueueWorkItem for the purpose of deferring work I couldn’t do at
> DISPATCH_LEVEL, but I have zero experience with adding multiple threads due
> to inherent HW parallelism.
> thanks,
> Daniel Nemiroff
>
>
> —
> You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
Hi Daniel,
Monday, October 29, 2001, 7:23:13 PM, you wrote:
ND> In my driver I need to send a single request to two HW devices in parallel.
ND> I’m planning on spinning two threads to do the work, while returning pending
ND> in the original.
ND> I was wondering if I should use a WorkItem (using IoQueueWorkItem) or create
ND> s system thread (using PsCreateSystemThread)?
ND> I’m asking because I’ve never used PsCreateSystemThread. I’ve used
ND> IoQueueWorkItem for the purpose of deferring work I couldn’t do at
ND> DISPATCH_LEVEL, but I have zero experience with adding multiple threads due
ND> to inherent HW parallelism.
ND> thanks,
ND> Daniel Nemiroff
ND> —
ND> You are currently subscribed to ntdev as: xxxxx@infpres.com
ND> To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
It’s OK to create system threads. WorkItems are too processed in the
system threads that are specially created for this purpose at boot
time, but depending on the WorkItemQueue type (Critical, Delayed or
HyperCritical) these threads have different priorities. These threads
simply pump the WorkItemQueues to process and run WorkItem routines.
It ain’t too hard to use PsCreateSystemThread() function to create a
system thread.
–
Best regards,
Konstantin Manurin (aka NizeG) xxxxx@infpres.com
xxxxx@beep.ru
xxxxx@yandex.ru
xxxxx@mail.ru
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
> In my driver I need to send a single request to two HW devices in parallel.
I’m planning on spinning two threads to do the work, while returning pending
You can use associated IRPs, provided you’re not below the filesystem.
If you’re below the filesystem - invent your own associated IRP mechanism, this is cheaper and better then the thread.
Max
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com