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...


Posts on similar topics...

28 Responses

  • Wed 17 Dec 2008
  • 2:49 PM
  •  avatar #1

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

  • Wed 17 Dec 2008
  • 3:29 PM
  • julian m bucknall avatar #2

julian m bucknall said...

Petter: Cool, I'm glad the article helped.

Cheers, Julian

  • Sun 11 Oct 2009
  • 7:15 AM
  •  avatar #3

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

  • Wed 11 Nov 2009
  • 5:33 PM
  •  avatar #4

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

  • Fri 25 Dec 2009
  • 6:17 AM
  •  avatar #5

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.

  • Sat 26 Dec 2009
  • 4:38 AM
  • julian m bucknall avatar #6

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

  • Thu 18 Mar 2010
  • 6:25 PM
  •  avatar #7

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

  • Fri 19 Mar 2010
  • 8:17 AM
  • julian m bucknall avatar #8

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

  • Sun 21 Mar 2010
  • 3:02 PM
  •  avatar #9

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>>(...);

}

}

  • Mon 22 Mar 2010
  • 12:01 PM
  • julian m bucknall avatar #10

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

  • Mon 22 Mar 2010
  • 2:54 PM
  •  avatar #11

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

  • Fri 07 May 2010
  • 12:14 AM
  •  avatar #12

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

再次感谢您.

  • Sat 30 Oct 2010
  • 4:21 PM
  •  avatar #13

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!

  • Sat 30 Oct 2010
  • 4:58 PM
  • julian m bucknall avatar #14

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

  • Sat 30 Oct 2010
  • 5:00 PM
  • julian m bucknall avatar #15

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

  • Tue 23 Nov 2010
  • 6:05 PM
  •  avatar #16

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

  • Tue 23 Nov 2010
  • 8:07 PM
  • julian m bucknall avatar #17

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

  • Mon 06 Dec 2010
  • 8:12 AM
  •  avatar #18

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

  • Mon 06 Dec 2010
  • 5:22 PM
  • julian m bucknall avatar #19

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

  • Tue 07 Dec 2010
  • 1:01 AM
  •  avatar #20

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

  • Wed 12 Jan 2011
  • 12:08 PM
  •  avatar #21

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

  • Tue 23 Aug 2011
  • 11:20 PM
  •  avatar #22

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

  • Wed 24 Aug 2011
  • 7:40 AM
  • julian m bucknall avatar #23

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

  • Thu 25 Aug 2011
  • 3:08 AM
  •  avatar #24

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!

  • Mon 19 Sep 2011
  • 5:44 PM
  •  avatar #25

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

  • Mon 19 Sep 2011
  • 6:51 PM
  • julian m bucknall avatar #26

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

  • Wed 30 Nov 2011
  • 1:58 PM
  •  avatar #27

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

  • Wed 30 Nov 2011
  • 5:34 PM
  • julian m bucknall avatar #28

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

Some MarkDown is allowed, but HTML is not. (Click to learn more.)

  • Emphasize with italics: surround word with underscores _emphasis_
  • Emphasize strongly: surround word with double-asterisks **strong**
  • Inline code: surround text with backticks `IEnumerable`
  • Unordered list: start each line with an asterisk, space * an item
  • Ordered list: start each line with a digit, period, space 1. an item
  • Insert code block: start each line with four spaces
  • Insert blockquote: start each line with right-angle-bracket, space > Now is the time...

Search

About Me

I'm Julian M Bucknall, the M because it's my middle initial and because I and the other Julian Bucknall (the movie guy) would like to differentiate ourselves.

I'm a programmer by trade, an actor by ambition, and an algorithms guy by osmosis. I write articles for PCPlus in my spare time, not that there's much of that.

Julian M Bucknall Apart from that, an ex-pat Brit, atheist, microbrew enthusiast, Pet Shop Boys fanboy, slide rule and HP calculator collector, amateur photographer, Altoids muncher.

DevExpress

I'm Chief Technology Officer at Developer Express, a software company that writes some great controls and tools for .NET and Delphi. I'm responsible for the technology oversight and vision of the company.

Validation

Validate markup as HTML5 (beta)     Validate CSS

Bottom swirl

Archives

February 2012 (3)
SMTWTFS
« Jan  
1234
567891011
12131415161718
19202122232425
26272829

Like this Archive Calendar widget? Download it here.

Social networking

Google ads

The OUT Campaign

The OUT Campaign

My Tweets

  • @TerriMorton "The Texan-ized Eiffel Tower" <shudders, whimpers in corner> /cc @rachelreese
  • One of my blog readers found this awesome picture of Roger Moore modeling a pullover in a "Father and Son" pattern http://t.co/DRs4dLSu
  • @RachelHawley First Vaseline, then a drill. It's a good job I have no imagination.
Bottom swirl