Page 3 of 3
Posted: Thu Jul 12, 2007 8:46 am
by Colonel Kernel
You also have to make sure that getInstance() is either protected by a lock of some kind, or is first called with interrupts disabled (in case interrupt handlers call getInstance()) before any threads are created. Or you do what I do and have a separate init() method that gets called very early in kernel initialization before getInstance() is ever called. This is one reason why I try to avoid implementing Singleton with a pointer instead of a global object whenever possible (but in my kernel, it's not really possible because I need a predictable order of initialization).
Posted: Sun Jul 15, 2007 3:55 am
by AndrewAPrice
I'm trying to minimize the use of assembly as much as possible (one exception is the stublet which includes the multiboot header and jumps to my C++ code). The other places I require assembly (setting up interrupts and some registry stuff) I use inline assembly and wrap it heavily hidden away in C++ classes.
I come from an C++/Game programming background where we focus on readability/object-oriented'ness. I've tried to implement the same concepts (message passing between objects, customisability, taking advantage of threading) in my OS and in game programming. It's interesting to see how people from different backgrounds have implemented different solutions to the same problems.