Finally how bad is bad in terms of spin lock usage, if it is not too coarse
grained !
while ( lock !=0 & lock=1)
while (lock !=0 ) ;
Traffic jam doing bus locking ??? No not quite, this is optimized … as far
as it gets, of course I dont remember offhand all the ramification, but for
write-thru caches …
Yes may be I’m OT, but I’ve to make a point too. Frankly anytime we try to
do optimisation on our own hand, should be based on a comparative studies
along with the OS provided APIs, and please note I’m not trying to say or
object about the suggestion(s) others and mine too. There is a high
likelyhood that the implementor would be missing something, so I would first
evaluate what is in existence, does it fit my model, if not what lacks, and
how mine is better …
All the points are very good, I just wanted to give it a twist for good
discussion or to think about things that we might forget to consider …
that’s all !
Finally between cache and memory, what order of magnitude differences ???,
the hw providers would not go at length to comeup with 3 or more levels of
cache if memory speed were close to cache( ~ register) speeds …
-pro
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Prokash Sinha
Sent: Monday, September 13, 2004 9:30 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Spinlocks
Also link list or any truely dynamically allocated structure is a pain in
the horrendous thinking from the cache-point-of-view, so any pre-fabricated
ddk/os provided api for TLB emulation would surely help here !!!
-pro
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Prokash Sinha
Sent: Monday, September 13, 2004 9:08 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Spinlocks
Just dropping my A* wide open :-). Kick as you please 
May be one or more thing to remember is not such the size of the list :).
How frequently
it would execute, it is possible that the list might not go over 300, and
each element ie. sizeof (struct node) might be 32 or 64 bytes, then ddk/os
provided TLB would be a choice . Sometime hash-collison, and the cost of
hash-function might become a overhead too !!. If it is on a really busy
execution path, hashing cost should be looked carefully too 
-pro
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of xxxxx@tab.at
Sent: Monday, September 13, 2004 8:41 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] Spinlocks
In this instance, being slow means less typing 
Nah, in this instance I just typed a lot of food for my backspace key *g*
Fast “find” structures would be a really nice thing to have from the DDK.
If they were implemented in the DDK using one fixed block-size (for e.g.
b-trees) from one common lookaside-list (private lal optional?) and if the
implementation was fast and rock-solid they’d surely be a nice thing for
some driver-developers. Anything like an FS or even a firewall could
surely make use of that.
Anyway, for 100 entries max. I’d probably stick with a list, for 100+
entries avg. I’d prefer something else. With strings as keys (did someone
mention filenames?) I’d probably use some form of hash anyway
(adler32/crc32) - even if it’s only a list. The comparsion of one DWORD
vs. a whole string should also give some noticable speedup.
Regards,
Paul Groke
Mats PETERSSON
Gesendet von: xxxxx@lists.osr.com
13.09.2004 17:19
Bitte antworten an “Windows System Software Devs Interest List”
An: “Windows System Software Devs Interest List”
Kopie:
Thema: Re: [ntdev] Spinlocks
In this instance, being slow means less typing 
Indeed a good suggestion, using a faster way to find the relevant data
doesn’t remove the problem, but it certainly helps reduce the locked time.
Good suggestion, I should’ve thought of it… 
–
Mats
xxxxx@lists.osr.com wrote on 09/13/2004 04:13:59 PM:
> Ah, I’m always too slow
One thing still left to say - you could
think
> about alternative data-structures if your list can get very big. Like
> hash-maps, b-trees or even a red-black-tree. That way you don’t avoid
the
> lock but you can reduce the time it takes to find one entry. The
downside
> is that the structures are more complicated and you have to allocate
> additional storage for them (at least for hash-map and b-tree).
>
> Regards,
>
> Paul Groke
>
>
>
>
>
> Mats PETERSSON
> Gesendet von: xxxxx@lists.osr.com
> 13.09.2004 16:40
> Bitte antworten an “Windows System Software Devs Interest List”
>
> An: “Windows System Software Devs Interest List”
>
> Kopie:
> Thema: RE: [ntdev] Spinlocks
>
>
>
>
>
>
>
> As Peter said…
>
> However, if you find that other threads can modify the list, there may
be
> ways to avoid the spin-lock, if you can live with the side-effects:
> 1. Don’t ever REMOVE entries from the list, just mark them invalid. This
> means that you don’t have to worry about entries “going away” whilst
> you’re
> working on them (doing p = p->next isn’t a good thing if p isn’t valid
> because it’s been freed!).
> 2. If you want to ADD things, make sure that it’s done in a safe manner.
> This can be done in many different ways, but it’s fairly easy to use the
> ExchangeInterLocked to write to the “next” pointer, which makes the
> operation atomic. Of course, if the list if double linked, it may be a
bit
> harder to achieve an atomic write.
>
> But one thing that’s always going to be a problem if you have multiple
> threads access a list (or any other data structure) is what happens when
> an
> entry isn’t consistant: Consider a delete of an element, just after the
> element was found and passed on to some other place… so this ‘other
> place’
> is now using the element that is being deleted. Of course, spinlocks on
> the
> list don’t help here, and you can’t always spinlock the entire use of
the
> data that came out of the list (especially if you pass it to a different
> piece of code than yours and for an undefined time). This has to be
worked
> around by for instance having reference counts for the data in the list,
> so
> that you can’t delete the count.
>
> Another thing to consider: If this code is ALWAYS running at passive
> level,
> you can use for instance (fast)mutex’s to protect the code from being
> re-entered. This will not help your code in itself, but it will give the
> time waiting for the mutex to someone else, rather than using a spinlock
> which just spins away the cycles in a tight loop. Most unfriendly on
other
> tasks in the system. Of course, if this code runs at a higher than
PASSIVE
> IRQL, then you MUST use the spinlock, as asking the OS to wait for you
> isn’t allowed at higher IRQL.
>
> –
> Mats
>
>
> xxxxx@lists.osr.com wrote on 09/13/2004 03:09:57 PM:
>
> > if another processor could be modifying this list at the same time
> > then you have to have some protection. You’re the only one who can
> > tell us whether “Create List Links” can be modified by another
> > thread at the same time as this code is running. And once you tell
> > us that you’ll have your answer.
> >
> > -p
> >
> > From: xxxxx@lists.osr.com [mailto:
> > xxxxx@lists.osr.com] On Behalf Of Anurag Sarin
> > Sent: Monday, September 13, 2004 6:27 AM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] Spinlocks
>
> > If I have a code like this in my CREATE Dispatch routine. And if my
> > Link List can be of 100 elements or more.
> > ---------------------------------------------------
> > Acquire Spin Lock
> > If Create Link List has elements
> > {
> > If this filename found in Create Link List
> > {
> > Release Spin lock
> > Return SpyPassthrough
> > }
> > }
> > Release Spin lock
> > ----------------------------------------------------
> > Is there a need to do this operation using spin locks ? Will this
> > lead to unexpected behavior or performance loss for my driver.
> > Any comments ??
> > Regards,
> > Anurag
> > —
> > 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
> > ForwardSourceID:NT0000353E
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@tab.at
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
> Please visit us: www.tab.at www.championsnet.net
> www.silverball.com
>
>
>
> —
> Questions? First check the Kernel Driver FAQ at http://www.
> osronline.com/article.cfm?id=256
>
> You are currently subscribed to ntdev as: xxxxx@3dlabs.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com
> ForwardSourceID:NT00003572
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@tab.at
To unsubscribe send a blank email to xxxxx@lists.osr.com
Please visit us: www.tab.at www.championsnet.net
www.silverball.com
—
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
You are currently subscribed to ntdev as: xxxxx@garlic.com
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: xxxxx@garlic.com
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: xxxxx@garlic.com
To unsubscribe send a blank email to xxxxx@lists.osr.com