Hi,
I have written a driver which acquires spinlock and
goes in DISPATCH_LEVEL. This is done for
synchronization and concurrency issues for shared
data.
I also have a system thread running which also tries
to acquire spinlock while trying to access shared
data.
I want to know whether on a uniprocessor machine, once
i have acquired spinlock, no other thread can get
scheduled? can my process be preempted by other
thread?
Can more than one processes stay in dispatch level? On
uniprocessor system, 2 threads trying to acquire same
spinlock, will one thread spin till other releases it?
thanks
Uday
Send free SMS using the Yahoo! Messenger. Go to http://in.mobile.yahoo.com/new/pc/
> I want to know whether on a uniprocessor machine, once
i have acquired spinlock, no other thread can get
scheduled? can my process be preempted by other
thread?
On a uniprocessor machine the thread holding the spin lock will stay on the
processor. No other thread can run until the spin lock is released. In a
single processor system the spin lock mechanism only raises the IRQL to
DISPATCH_LEVEL IIRC.
Can more than one processes stay in dispatch level? On
uniprocessor system, 2 threads trying to acquire same
spinlock, will one thread spin till other releases it?
Not in a single processor system. The other thread won’t even run until you
release the spin lock is released and the IRQL drops. However on a multi
processor system the spin lock is both an IRQL raise and a real spin lock so
in this case your second thread would indeed wait until it could acquire the
spin lock.
Mike
Spinlock acquisition raises IRQL to DISPATCH_LEVEL. On this IRQL level you
thread never gets preempted and no other thread can be scheduled. If two
threads try to acquire spinlock at the same time one elevates IRQL and other
one never gets control until IRQL is lowered to PASSIVE_LEVEL. So, other
thread will not spin as it will not get chance to do that.
-htfv
----- Original Message -----
From: “Uday Mumbai”
To: “NT Developers Interest List”
Sent: Friday, June 27, 2003 9:20 AM
Subject: [ntdev] Multiple threads on DISPATCH_LEVEL
> Hi,
>
> I have written a driver which acquires spinlock and
> goes in DISPATCH_LEVEL. This is done for
> synchronization and concurrency issues for shared
> data.
> I also have a system thread running which also tries
> to acquire spinlock while trying to access shared
> data.
>
> I want to know whether on a uniprocessor machine, once
> i have acquired spinlock, no other thread can get
> scheduled? can my process be preempted by other
> thread?
> Can more than one processes stay in dispatch level? On
> uniprocessor system, 2 threads trying to acquire same
> spinlock, will one thread spin till other releases it?
>
> thanks
> Uday
>
> ________________________________________________________________________
> Send free SMS using the Yahoo! Messenger. Go to
http://in.mobile.yahoo.com/new/pc/
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@vba.com.by
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>
> I want to know whether on a uniprocessor machine, once
i have acquired spinlock, no other thread can get
scheduled?
Yes.
can my process be preempted by other
thread?
No.
Can more than one processes stay in dispatch level?
No.
uniprocessor system, 2 threads trying to acquire same
spinlock, will one thread spin till other releases it?
On uniprocessor, spinlock is implemented as raising the IRQL to
DISPATCH_LEVEL. This stalls the scheduler, and the code runs
non-preemptive.
Remember that you cannot touch anything pageable from DISPATCH_LEVEL.
Max
On Fri, 2003-06-27 at 01:20, Uday Mumbai wrote:
I want to know whether on a uniprocessor machine, once
i have acquired spinlock, no other thread can get
scheduled? can my process be preempted by other
thread?
One amplification to the other responses you have received - keep in
mind that your code can still be preempted by higher-IRQL code, for
example a hardware interrupt running code at DIRQL. Your code doesn’t
really have exclusive, run-to-completion use of the processor.
-sd
why I can receive mail list since two weeks ago?Is there anything wrong?
----- Original Message -----
From: “Maxim S. Shatskih”
To: “NT Developers Interest List”
Sent: Saturday, June 28, 2003 7:02 AM
Subject: [ntdev] Re: Multiple threads on DISPATCH_LEVEL
> > I want to know whether on a uniprocessor machine, once
> > i have acquired spinlock, no other thread can get
> > scheduled?
>
> Yes.
>
> >can my process be preempted by other
> > thread?
>
> No.
>
> > Can more than one processes stay in dispatch level?
>
> No.
>
> > uniprocessor system, 2 threads trying to acquire same
> > spinlock, will one thread spin till other releases it?
>
> On uniprocessor, spinlock is implemented as raising the IRQL to
> DISPATCH_LEVEL. This stalls the scheduler, and the code runs
> non-preemptive.
> Remember that you cannot touch anything pageable from DISPATCH_LEVEL.
>
> Max
>
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@emgsoft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com