Hi,
I’ve the following problem. I’ve a function that is executed at DISPATCH_LEVEL. I need to isolate that function and execute it at PASSIVE_LEVEL. (it’s legal to execute it at PASSIVE_LEVEL, sometimes the os does that, but on other occasions it’s executed at DISPATCH_LEVEL).
So I thought, if I:
- call the functiin with another name (fct2)
- reimplement the primary function so that this will append the request to al queue
- have a background worker thared running at PASSIVE_LEVEL that invokes the original function getting the parameters list from the queue.
Should this work ?
Is there a way to postpone the execution of a function util the system goes down to PASSIVE_LEVEL without initializing a new system worker thread ?
Thanks
Matteo
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
If you don’t want to pay the cost of managing your own system threads
you can just use the executive worker threads. In W2K/XP see
IoQueueWorkItem, in NT4 see ExQueueWorkItem. By the way, you don’t
actually have to have two functions, as your original function can just
check the IRQL, and if it is >= DISPATCH_LEVEL queue the workitem, else
perform the service. This avoids hideous code replication.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Matteo Pelati
Sent: Tuesday, November 06, 2001 5:04 PM
To: NT Developers Interest List
Subject: [ntdev] irql problem
Hi,
I’ve the following problem. I’ve a function that is executed at
DISPATCH_LEVEL. I need to isolate that function and execute it at
PASSIVE_LEVEL. (it’s legal to execute it at PASSIVE_LEVEL, sometimes the
os does that, but on other occasions it’s executed at DISPATCH_LEVEL).
So I thought, if I:
- call the functiin with another name (fct2)
- reimplement the primary function so that this will append the request
to al queue
- have a background worker thared running at PASSIVE_LEVEL that invokes
the original function getting the parameters list from the queue.
Should this work ?
Is there a way to postpone the execution of a function util the system
goes down to PASSIVE_LEVEL without initializing a new system worker
thread ?
Thanks
Matteo
You are currently subscribed to ntdev as: xxxxx@hollistech.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
First of all it all depends upon your driver and which kind of function you
are running. But out of the 3 methods last two should work, I have done
these implementations before and they worked well.
Third option - Calling this function with another name - I don’t know what
will it achieve ?
-----Original Message-----
From: Matteo Pelati [mailto:xxxxx@dolce.it]
Sent: Tuesday, November 06, 2001 2:04 PM
To: NT Developers Interest List
Subject: [ntdev] irql problem
Hi,
I’ve the following problem. I’ve a function that is executed at
DISPATCH_LEVEL. I need to isolate that function and execute it at
PASSIVE_LEVEL. (it’s legal to execute it at PASSIVE_LEVEL, sometimes the os
does that, but on other occasions it’s executed at DISPATCH_LEVEL).
So I thought, if I:
- call the functiin with another name (fct2)
- reimplement the primary function so that this will append the request to
al queue
- have a background worker thared running at PASSIVE_LEVEL that invokes the
original function getting the parameters list from the queue.
Should this work ?
Is there a way to postpone the execution of a function util the system goes
down to PASSIVE_LEVEL without initializing a new system worker thread ?
Thanks
Matteo
You are currently subscribed to ntdev as: xxxxx@fvc.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
>Is there a way to postpone the execution of a function util the system
goes down to PASSIVE_LEVEL without initializing a new system worker thread ?
If your currently executing at DISPATCH_LEVEL, there is no way to suspend
your “execution context” and let code at PASSIVE_LEVEL execute. By
definition, DISPATCH_LEVEL code is not preemptable. What’s often done is
you have a state machine, and your code records the next state as needing
to continue after work is done at PASSIVE_LEVEL… After the passive level
code runs, you can schedule a DPC to run at DISPATCH_LEVEL, resuming in the
correct place based on the state machine, or you may be able to just
continue in the thread that runs the PASSIVE_LEVEL code, by raising the
IRQL to DISPATCH_LEVEL (which avoids the overhead of queueing a DPC).
Often, this solution is just a work around to the real issue.
The best thing to do is: don’t get yourself into the situation where your
running DISPATCH_LEVEL code that needs to call PASSIVE_LEVEL only
functions. This takes planning ahead. My question would be, what are you
executing at DISPATCH_LEVEL that is not really priority critical and could
wait for normal thread scheduling? DISPATCH_LEVEL is supposed to be for
code that can’t wait for normal scheduling to wake it up. Executing at
DISPATCH_LEVEL for synchronization reasons is also common, although the
goal is to not spend unnecessary time at an elevated IRQL, as it degrades
the response time of code that REALLY does need to run at high priority.
Perhaps what you really need is code that’s basically running at
PASSIVE_LEVEL (like in a worker thread), but on occasion holds a spinlock
at DISPATCH_LEVEL, and you avoid calling PASSIVE_LEVEL only functions while
holding those spin locks?
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