LWN.net Logo

KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services

KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services

Posted Feb 27, 2008 21:58 UTC (Wed) by zlynx (subscriber, #2285)
In reply to: KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services by pphaneuf
Parent article: KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services

Your solution is not as ugly as another I've seen in C++ where the programmer used placement
new to reconstruct the object with a different derived type (but the same base type) in-place.

Now, that was scary.


(Log in to post comments)

KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services

Posted Feb 27, 2008 22:51 UTC (Wed) by pphaneuf (guest, #23480) [Link]

My way is ugly. That way is insane.

Still, I wish it was possible to manipulate vptrs and vtbls more in C++. Things like having two different implementations of a virtual method with the same signature inherited from two parents would make sense, for example (say, the "draw" methods you get while deriving from both Drawable and Cowboy).

KHB: Synthesis: An Efficient Implementation of Fundamental Operating Systems Services

Posted Feb 28, 2008 20:59 UTC (Thu) by nix (subscriber, #2304) [Link]

Insane?

Oh.

So, er, I should be ashamed that I did almost exactly that (via a custom 
allocator layered atop big mmap()ed hunks) in C about a year ago? (Well, 
it was more like a twisted sort of RCU: I'd construct a new instance that 
was a copy of the old one with a zero reference count, then changing 
pointers in the new instance's VMT-analogue, translating the object's data 
into a new representation at the same time. The old instance got 
reference-zapped when nobody was executing methods via those pointers 
anymore.)

(yes, there were pressing reasons. It was a bundle of fun, as well. :) )

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds