Hi All,
what happens if a spinlock is taken in a loop with out releasing?
I tested the following loop in my ndis driver , loop
is excecuted fine both in 98 and 2000 .
NdisAllocateSpinLock(&Lock);
for ( i = 0; i < 100; i++)
{
NdisAcquireSpinLock(&Lock);
}
DbgPrint(“\n NdisAcquireSpinLock test fail”);
I was happened to test the above , as I found in my ndis driver
that updating a global variable by more than one thread was not proper even
after taking spinlocks.
Driver is checked build .
OS is free build.
Machine is p3 (uniprocessor).
I think the same may not work in checked build OS.
Is there any other way to do arithmetic operations
atomically with out use of spinlocks in NDIS drivers.?
(NdisInterlockedIncrement doesnt do for my requirements).
Regards,
R Chakrapani.
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
> NdisAllocateSpinLock(&Lock);
for ( i = 0; i < 100; i++)
{
NdisAcquireSpinLock(&Lock);
}
DbgPrint(“\n NdisAcquireSpinLock test fail”);
Acquiring Spin lock normal procedure :
- Allocate Spin lock structure using non-paged mem.
- AcuireSpin lock u will get Old irql as return.
- Do some processing…
- Release Spin lock by passing Old irql as parameter.
But in ur above loop it is destroying old irql values U can only restore
last acquired spin lock properly.
I doubt calling Spin lock for 100 times is not correct ( I am not sure about
this ).
Regards,
Satish K.S
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
On a uniprocessor, aquire spinlock merelely raises IRQL to DISPATCH_LEVEL.
(there is no “spinning”). That’s perhaps why you loop executed just fine.
Also, on W98 NDIS spinlocks are NOPs - do nothing - unless
you complile your driver with /DUSE_KLOCKS switch.
On 05/25/01, ““chakrapani” ” wrote:
> Hi All,
>
> what happens if a spinlock is taken in a loop with out releasing?
>
> I tested the following loop in my ndis driver , loop
> is excecuted fine both in 98 and 2000 .
>
> NdisAllocateSpinLock(&Lock);
> for ( i = 0; i < 100; i++)
> {
> NdisAcquireSpinLock(&Lock);
> }
> DbgPrint(“\n NdisAcquireSpinLock test fail”);
>
>
> I was happened to test the above , as I found in my ndis driver
> that updating a global variable by more than one thread was not proper even
> after taking spinlocks.
>
>
> Driver is checked build .
> OS is free build.
> Machine is p3 (uniprocessor).
>
> I think the same may not work in checked build OS.
>
> Is there any other way to do arithmetic operations
> atomically with out use of spinlocks in NDIS drivers.?
> (NdisInterlockedIncrement doesnt do for my requirements).
>
>
>
> Regards,
> R Chakrapani.
>
>
> —
> 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
> what happens if a spinlock is taken in a loop with out releasing?
I tested the following loop in my ndis driver , loop
is excecuted fine both in 98 and 2000 .
NdisAllocateSpinLock(&Lock);
for ( i = 0; i < 100; i++)
{
NdisAcquireSpinLock(&Lock);
On SMP binaries, the CPU will hang on the second iteration.
On UP binaries, it will have the same effect as acquiring once.
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
Hi ,
The driver which I ran in 98 is basically
compiled using 2000 ddk and not 98 ddk.
I checked specifically to which my call of ndisacquirespinlock is
getting linked , it was the exported function ndisacquirespinlock
( As binary_compatable flag is on).
The problem I am facing is the improper updation of
some global variables even they are protected well by the spinlocks.
Regards,
R Chakrapani.
----- Original Message -----
From:
To: “NT Developers Interest List”
Sent: Friday, May 25, 2001 9:46 AM
Subject: [ntdev] Re: does NdisAcquireSpinLock work properly in 2000 &98?
> On a uniprocessor, aquire spinlock merelely raises IRQL to DISPATCH_LEVEL.
> (there is no “spinning”). That’s perhaps why you loop executed just fine.
> Also, on W98 NDIS spinlocks are NOPs - do nothing - unless
> you complile your driver with /DUSE_KLOCKS switch.
>
> - Vitaly
>
>
> On 05/25/01, ““chakrapani” ” wrote:
> > Hi All,
> >
> > what happens if a spinlock is taken in a loop with out releasing?
> >
> > I tested the following loop in my ndis driver , loop
> > is excecuted fine both in 98 and 2000 .
> >
> > NdisAllocateSpinLock(&Lock);
> > for ( i = 0; i < 100; i++)
> > {
> > NdisAcquireSpinLock(&Lock);
> > }
> > DbgPrint(“\n NdisAcquireSpinLock test fail”);
> >
> >
> > I was happened to test the above , as I found in my ndis driver
> > that updating a global variable by more than one thread was not proper
even
> > after taking spinlocks.
> >
> >
> > Driver is checked build .
> > OS is free build.
> > Machine is p3 (uniprocessor).
> >
> > I think the same may not work in checked build OS.
> >
> > Is there any other way to do arithmetic operations
> > atomically with out use of spinlocks in NDIS drivers.?
> > (NdisInterlockedIncrement doesnt do for my requirements).
> >
> >
> >
> > Regards,
> > R Chakrapani.
> >
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@procsys.com
> > To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
>
> —
> You are currently subscribed to ntdev as: xxxxx@procsys.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
Hi ,
I am thinking that if a spinlock is acquired , then no one else can acquire
the same spinlock untill it is been released so that
the spinlock acquired thread can access the shared resource
explicitly or can execute critical code. And I think trying to acquire a
already acquired spinlock makes the taker to wait untill
its been released.
If the above concept doesnt work in uniprocessor , how
shared resources are protected and how critical sections
are executed ?
shared resorces are used with
If that is the case how can we protect a shared resources in
uniprocessor
----- Original Message -----
From: “Maxim S. Shatskih”
To: “NT Developers Interest List”
Sent: Friday, May 25, 2001 10:05 PM
Subject: [ntdev] Re: does NdisAcquireSpinLock work properly in 2000 &98?
> > what happens if a spinlock is taken in a loop with out releasing?
> >
> > I tested the following loop in my ndis driver , loop
> > is excecuted fine both in 98 and 2000 .
> >
> > NdisAllocateSpinLock(&Lock);
> > for ( i = 0; i < 100; i++)
> > {
> > NdisAcquireSpinLock(&Lock);
>
> On SMP binaries, the CPU will hang on the second iteration.
> On UP binaries, it will have the same effect as acquiring once.
>
> Max
>
>
> —
> You are currently subscribed to ntdev as: xxxxx@procsys.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
>
I am thinking that if a spinlock is acquired , then no one else can
acquire
the same spinlock untill it is been released so that
the spinlock acquired thread can access the shared resource
explicitly or can execute critical code. And I think trying to acquire a
already acquired spinlock makes the taker to wait untill
its been released.
If the above concept doesnt work in uniprocessor , how
shared resources are protected and how critical sections
are executed ?
In UniProcessor it raises only IRQL to DISPATCH_LEVEL. Thread Switching dont
work. U can execute ur critical section code at this time. In MP real
hardware atomic operation will happen using Instruction BTS ( Bit Test and
Set ).
Regards,
Satish K.S
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