tag:blogger.com,1999:blog-29331675.post1488081948103738418..comments2024-03-05T17:37:00.995+01:00Comments on The Delphi Geek: Three steps to the blocking collection: [2] Dynamically allocated queuegabr42http://www.blogger.com/profile/06903558857617342477noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-29331675.post-39012290547893554502010-02-04T20:13:24.518+01:002010-02-04T20:13:24.518+01:00@Xepol: A number of states could definitely be red...@Xepol: A number of states could definitely be reduced, but as I had one whole byte of space to use, I was not trying to minimize them. They are defined so that the concept is easy to understand. If you go down to the 'modifying' bit, then you're working on a different solution (or so I believe).<br /><br />A block read counter is not possible to implement (I believe), at least not without locking.<br /><br />The destruction could possibly be implemented your way but I don't see any significant advantage.<br /><br />The best you can do: Take my code and modify it your way. Test it. Run the bench. Then report back. In the worst case you'll learn something and that will be good for you. In the best case you'll wildly improve my approach and that will be good for the community.gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-63666775272277078322010-02-04T20:02:18.364+01:002010-02-04T20:02:18.364+01:00Interestingly, there is very little difference bet...Interestingly, there is very little difference between code using CAS8 and CAS32. But as the code is simpler with CAS8, I'll do the change.gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-31480608874834472252010-02-04T19:58:48.191+01:002010-02-04T19:58:48.191+01:00I'm still digging through this article, but my...I'm still digging through this article, but my first instinct is to say it looks over complicated.<br /><br />By that I mean that the tag for the values is perhaps doing too much. The lock for each unique item could be "modifying/not modifying", and then another list based lock for actions that actually affect the lists' structure on the whole.<br /><br />If you need to go as far as to protect out of band read access, then an interlocked inc/dec for a read pointer that counts how many people are reading the record.<br /><br /><br />Record destruction could then look like:<br /><br /> spin until not modifying, set to modifying<br /> spin until read count=0<br /> spin until list locked<br /> destroy object<br /> update list<br /> unlock list<br /><br />Then a few rules such as read locks fail while the record is being modified, modifying fails if the read counter isn't 0. Head, Tail, any next/previous pointers would all be protected by the list wide lock.<br /><br />I could be over-simplifying, but as I said, I am still digging throught the article - these are just first impressions.Xepolnoreply@blogger.comtag:blogger.com,1999:blog-29331675.post-35466696339645128812010-02-04T19:56:35.224+01:002010-02-04T19:56:35.224+01:00'Cause I didn't knew that this is also pos...'Cause I didn't knew that this is also possible to do :(( My assembler skills are not that great.<br /><br />Thanks for the hint, I'll retest the code with CAS8 and report back.gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-70590946171126472382010-02-04T19:47:19.697+01:002010-02-04T19:47:19.697+01:00Super... :)
What about CAS8 instead function TOmn...Super... :)<br /><br />What about CAS8 instead function TOmniTaggedValue.CASTag?<br /><br />function CAS8(const oldValue, newValue: byte; var destination): boolean;<br />asm<br /> lock cmpxchg byte ptr [destination], newValue<br /> setz al<br />end; { CAS8 }<br /><br />LP GJGJhttps://www.blogger.com/profile/17738650133050147612noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-36456168950509446242010-02-04T16:57:10.158+01:002010-02-04T16:57:10.158+01:00Great article!
This made me reread the "LOCKE...Great article!<br />This made me reread the "LOCKED ATOMIC OPERATIONS" chapter of the Intel's manual. Just in case someone else wants to do that too, its 8.1 of http://www.intel.com/assets/PDF/manual/252046.pdf, but is 7.1 in the 2007 printed version i have.Javier Santo Domingonoreply@blogger.comtag:blogger.com,1999:blog-29331675.post-60104926787330552482010-02-04T15:05:42.159+01:002010-02-04T15:05:42.159+01:00Thank you. I know it's a tad long but I didn&#...Thank you. I know it's a tad long but I didn't want to split it into 3-5 smaller articles.gabr42https://www.blogger.com/profile/06903558857617342477noreply@blogger.comtag:blogger.com,1999:blog-29331675.post-1122180590011624822010-02-04T14:56:42.452+01:002010-02-04T14:56:42.452+01:00Very, very interesting article!!Very, very interesting article!!Anonymousnoreply@blogger.com