Contact Me
Firstly, if you want to respond to a post, just add a comment.
More informal is Twitter: JMBucknall
Lastly, if you want to keep it private, my email is julianb@boyet.com. And I have good spam blockers...
Firstly, if you want to respond to a post, just add a comment.
More informal is Twitter: JMBucknall
Lastly, if you want to keep it private, my email is julianb@boyet.com. And I have good spam blockers...
28 Responses
Petter Mattsson said...
Hi !
I just read one of your earlier posts about a recursive version of the selection sort. I´ve been having a bit of a hard time getting the recursive thinking in to my head, but after reading trough your way of reasoning how to rebuild the sort it just "clicked". So.....thanks!!
//Petter
julian m bucknall said...
Petter: Cool, I'm glad the article helped.
Cheers, Julian
Nasser Wahby said...
Hallo their,
I have a question about a book , if you have any book about the data structures for starter.
From the beginning , i mean the beginning sequention and selection , iteration, of cours the book must include a lot of case and the soulations.
And then the rule of pascal, or Delphi , dosn't matter.
Please , and again please if you have any paper work als it be suseful,.
My name is Nasser Wahby
im living in Belgium , so i am wating your replay.
Best Regardes
Nasser
Mick said...
Hi Julian,
just a quick one to say thanks for an old article and program on ISO 8601 for Week number. I spend more time testing and figuring out why other implementations where not working and stubbled across yours in a small thread in a response to one that didnt work. Nice piece of work and thanks.
On a side note.. I brought Telerix controls into a few client companies that I worked in, a few years ago. At first it worked well but once we tried something not out of the box... duh! I then moved to dev express and we pushed those controls to the limit also. Some cool stuff, modal dialogs on ASP etc ... all great. Yeah ok I coming to the 'But' bit :-) just remember in designing to keep it simple stupid. I did notice after each release that the functionality grew to such a size that it was like learning a hole new programming skill. So if you can in there... keep it simple as the controls are great...
thanks again... Mick
DoctorGauss said...
Hello, Mr. Bucknall.
I'm from Russia and Yesterday I have buy your book The Tomes of Delphi Algorithms and Data Structures (in translate for russian language). It's fantastic book, thank for your job. I'm begining non-professional programmer and this book very useful for me.
With best wishes!
P.S. Sorry for my bad English.
julian m bucknall said...
DoctorGauss: Good luck with the book! Glad you like it. I also have a Russian translation of it, although I can't read it. By the way, your English is just fine.
Cheers, Julian
Dave said...
Hi Julian,
I'm using an older version of your lock free queue and I'm occasionally an NullReferenceException in Dequeue() thrown from the line
item = oldHeadNext.Item;
Is this (http://www.boyet.com/Articles/LockfreeQueue.html) the latest version you've posted? It's newer than the version I used so hopefully the issue I'm experiancing is the thing you fixed.
Regards
Dave
julian m bucknall said...
Dave: The code shown on that page is pretty much the latest version. However you can get the really 100% up-to-date :) version here: www.boyet.com/.../LockFreeCode.zi
Cheers, Julian
Dave said...
Hi Julian,
The zip file is the same code which I'm experiancing the exception.
In the code below, oldHeadNext is tested for null if oldHead == oldTail, but not if it isn't. I'm seeing it null inside the else statement, NullReferenceException is thrown from the line where item is assigned oldHeadNext.Item.
if (oldHead == head) {
if (oldHead == oldTail) {
if (oldHeadNext == null) {
return false;
}
SyncMethods.CAS<SingleLinkNode<T>>(...)
}
else {
item = oldHeadNext.Item;
haveAdvancedHead =
SyncMethods.CAS<SingleLinkNode<T>>(...);
}
}
julian m bucknall said...
Dave: I can't reproduce this at all. I've written a multithreaded app that uses two threads to enqueue, and two to dequeue, and run it on my four-core desktop enqueuing 100,000,000 integers. No problem. I added 4 more dequeuers. No problem.
I've reviewed the code as well, going back to my original source (the Michael and Scott paper). It's good.
So, have you got a reproducible test case? If so, please email me on julianb@boyet.com. I promise to take a look, asap.
Cheers, Julian
Dave said...
Hi Julian,
I've not been able to reproduce outside the production application (I used ints like you). I'll keep trying, I'm using the lock free queue in a Producer / Consumer scenario. Any number of thread can enque an object but since the source is a WCF MSMQ endpoint generally it always seems be the same thread. There is only ever 1 thread dequeuing.
Regards
Dave
caoweimin said...
Hi Julian,
I have read your book-The Tomes of Delphi Algorithms and Data Structures several times. It deserves reading really. Today I test TtdSkipList using 10,000,000 Pointers and I found a bug in TtdSkipList.Add procedure.
// Source begin=================
procedure TtdSkipList.Add(aItem : pointer);
var
i, Level : integer;
NewNode : PskNode;
BeforeNodes : TskNodeArray;
begin
{search for the item and initialize the BeforeNodes array}
if slSearchPrim(aItem, BeforeNodes) then
slError(tdeSkpLstDupItem, 'Add');
{calculate the level for the new node}
Level := 0;
while (Level <= MaxLevel) and (FPRNG.AsDouble < 0.25) do
inc(Level);
{if we've gone beyond the maximum level, save it}
if (Level > MaxLevel) then
inc(FMaxLevel);
//Source end ===============
The last line increment FMaxLevel, so it is possible that FMaxLevel exceed tdcMaxSkipLevels, 12. This situation's probability is very low, but it happened while testing with large data volumn.
Best Regardes
Caoweimin
再次感谢您.
Ken Beaudrie said...
I purchased the second printing of your book "Algorithms and Data Structures." I tried to download the source code from the book at www.boyet.com/boyet/fixedarticles/dadsbook.html but the file to be downloaded appears to be corrupted. I can neither open the file online or sucessfully download a copy that can be opened. Can you help?
Thanks for the great book!
julian m bucknall said...
Ken: Very puzzled. I just downloaded the zip file from the link on that page and it was fine (I could open the zip file and open one of the files in the zip archive). So email me (the address is above) and I'll email the file to you.
Cheers, Julian
julian m bucknall said...
caoweimin: Sorry about that: I missed the notification email that said you'd commented. You are correct: I should have put in some code to throw an exception if the level was incremented past the tdcMaxSkipLevels value.
Cheers, Julian
Scott said...
Hi Julian,
I stumbled across your old blog whilst researching a lock-free FIFO queue and Hazard Pointers.
I am using the Michael-Scott algorithm for a lock-free queue, but I'm trying to do a presentation that demonstrates the ABA-prone CAS operations in the enqueue method, and I'm not too sure how to actually implement the hazard pointers.
Since I enjoyed your old blog and appreciated the coding explanations, I was hoping you could point me to the "Next time we'll be looking at the actual implementation in C# of the hazard pointer system. " portion, referenced from http://www.boyet.com/Articles/HazardPointersTwo.html.
Specifically, I see you're using some (presumably unimplemented) call to MagicMemoryManager.MarkAsHazardPointer.
I need some magic in my memory management =)
I appreciate any help and keep it up!
Cheers,
Scott
julian m bucknall said...
Scott: I wrote something for hazard pointers in Delphi around about that particular time, but never went further with converting that to C#. I was never particularly happy with it in Delphi (it was, to put it mildly, pretty junky code -- I seem to remember you had to state up front how many hazard pointers you wanted to use and TLS was in there somewhere) so put it aside for the day I would reconsider it in C#. That day never really came.
Cheers, Julian
Laurent said...
Hi Julian,
First of all, I would like to say that, I am a fervent admirer of resolutions whom you offer by yours articles, book or by your DevExpress commercial way.
I've read some months ago (maybe some years ago), a very nice article from you. This one displayed a very clever principle used under ExpressEditor and concerns, the Properties property (Tcx...Properties). You had explained how to implement and unfortunatly, I cannot retrieve this/these articles. Could you help me to point me in right direction ?
Thank you very much for your precious contribution in the Delphi's world.
Best regards,
Laurent
julian m bucknall said...
Laurent: It wasn't me, I'm afraid. Possibly it was Richard Morris -- I know he did a couple of talks for CodeRage in 2009 on behalf of DevExpress and posted the code. It's a two-parter and you can find it here: http://jmbk.nl/Za8i2
and here: http://jmbk.nl/Qt9a5
Cheers, Julian
Laurent said...
Y E S Y E S Y E S .....
Thank you very much.
I'm very disappointed, you would really have been able to be quicker than Richard to write them. ;-)
Best regards and très bonne continuation.
Laurent
PeteK said...
Julian,
I'd be interesting in seeing a TOC of your algorithms book ,if you have one at hand. Failing that, was it reviewed in the Dlephi Magazine ? What a fine resource that was (is).
Pete K
Stefan Mauerhofer said...
Hi Julian
I'm a swiss programmer working at a bank and interested in lock-free algorithms. I have a minor understanding problem with your queue implementation. In the enqueue method you write
if (SyncMethods.CAS<SingleLinkNode<T>>(ref tail.Next, null, newNode)) {...
The point is the tail.Next reference. Isn't it possible that tail variable changes after the parameters are pushed on the stack and before SyncMethods.CAS is called? Is it possible to replace this peace of code with the following without breaking the algorithm?
if (SyncMethods.CAS<SingleLinkNode<T>>(ref oldTail.Next, null, newNode)) {...
Please excuse my disturbance, I'm not shure if I'm completely wrong.
PS: I like the out campaign very much
julian m bucknall said...
Stefan: The whole point of that statement is to attach the new node onto the end of the queue (that is, `tail.Next`). So if it's null, the new node gets attached and everything is fine. Remember that `CAS` compares the first parameter (it's a `ref` parameter so it's `CAS` that will dereference it, not the call) with the second, and sets it equal to the third if the comparison is equal. As an atomic operation.
The problem with `oldTail` is that it *may* have been dequeued a while back and `oldTail.Next` may be null by bad luck. If that is the case we've just successfully attached the new node onto an orphaned tail. Not what we want.
BTW: make sure you are using [the latest code here](http://blog.boyet.com/blog/blog/testing-the-lock-free-queue/).
Cheers, Julian
Stefan Mauerhofer said...
Hi Julian
Thanks for the explanation. Now I do understand your code and the error in my thoughts. Thank you very much!
bosjo said...
Opera complains that the pages on this site are not well-formed XML:
XML parsing failed
XML parsing failed: syntax error (Line: 6, Character: 105)
I suppose this is because one of the links in the header is missing the "/" at the end.
/Bo S
julian m bucknall said...
@bosjo: Thanks for the heads-up. Actually it was because a link tag was badly formed (it had a quoted string with an ampersand in it). The moral of the story is, always read code you add to your site, especially if it comes from Google.
I've now checked the site with the XHTML validator to make sure it validates correctly. Must add note to self to do this periodically...
Cheers, Julian
bosjo said...
Again, Opera is complaining about the XML -- I think it is the "<" in "if node.precedence < priorPrecedence" it doesn't like...
/Bo S
julian m bucknall said...
@bosjo: Thanks again. This time I had to take a short cut to publishing the post because of issues I was having with GoDaddy's hosting and the MetaWeblog interface.
Again: must add note to self to check this periodically.
Cheers, Julian
Leave a Response