Linked by Thom Holwerda on Fri 10th Jul 2009 22:53 UTC, submitted by poundsmack
OSNews, Generic OSes Captain, we've encountered another one. FreeNOS is a microkernel-based operating system written for learning purposes. "The system is very experimental, yet it currently supports virtual memory, simple task scheduling, and interprocess communication (IPC). It currently contains support for a few devices, including VGA, keyboard, i8250 serial, and PCI host controllers. FreeNOS has an experimental implementation of several filesystems, such as the virtual file system, procfs, tmpfs, and ext2fs. Current application libraries include libposix, libc, libteken (terminal emulation), and libexec (executable formats). All source code has been documented with Doxygen tags."
E-mail Print r 0   · Read More · 15 Comment(s)
Order by: Score:
C++
by Vanders on Sat 11th Jul 2009 10:45 UTC
Vanders
Member since:
2005-07-06

No comments? How sad.

I took a quick look at the SVN repo and was surprised to see the kernel is written in C++. Not only that, but the code is very clean and readable. As a result of using STL classes for stuff like lists & queues the entire kernel code base appears to be tiny: bear in mind that the large portion of any kernels time is spent creating, modifying and iterating lists and arrays!

So, a microkernel written in C++...that could just alienate almost every OS developer on the planet. Good for them!

Reply Score: 4

RE: C++
by righard on Sat 11th Jul 2009 10:59 UTC in reply to "C++"
righard Member since:
2007-12-26

Yes, I always wondered why there is so much aversion against C++ in the kernel world. I think the language can abstract a kernel a lot, make segmentation faults a real choir to produce, and allows the kernel to be easily extended without rewriting large parts of code or resort to ugly hacks.
I really can't believe speed is an issue. I think it's an flawed excuse for conservative programmers.

Reply Score: 2

RE[2]: C++
by kaiwai on Sat 11th Jul 2009 11:37 UTC in reply to "RE: C++"
kaiwai Member since:
2005-07-06

Yes, I always wondered why there is so much aversion against C++ in the kernel world. I think the language can abstract a kernel a lot, make segmentation faults a real choir to produce, and allows the kernel to be easily extended without rewriting large parts of code or resort to ugly hacks.
I really can't believe speed is an issue. I think it's an flawed excuse for conservative programmers.


One of the reasons I have heard (this isn't my opinion btw - so any idiots out there who want to moderate me down claiming to me by opinion - jump off a cliff head first) are when projects become large C++ apparently has a habit of becoming rather unreadable and problematic. Personally I think that reason is more born out of a refusal by some to learn C++ but I could be wrong.

Writing it in C++ isn't new though, there are lots of kernels in the commercial world that make extensive use of C++ (I/O kit in Mac OS X for example which is based on embedded C++) so I guess it has more to do with C being the first taught at many universities. Although when I went through polytech we were taught basic programming fundamentals in Visual Basic but then moved to teaching C++ as the 'proper language' (visual basic was only a teaching tool).

Reply Score: 3

RE[3]: C++
by strcpy on Sat 11th Jul 2009 11:54 UTC in reply to "RE[2]: C++"
strcpy Member since:
2009-05-20

I must admit that C++ is often the one and only reason why I won't get involved in some projects I otherwise admire. Like Haiku and perhaps this FreeNOS too.

I won't go into details why, but perhaps I'll summarize that for kernel development, C++ offers too much with too little gain.

For an interested reader, the internet is full of debates where some of the most prominent kernel developers of today debate the usage of C++ in kernels. Interesting reading.

Reply Score: 1

RE[4]: C++
by kaiwai on Sat 11th Jul 2009 12:45 UTC in reply to "RE[3]: C++"
kaiwai Member since:
2005-07-06

I must admit that C++ is often the one and only reason why I won't get involved in some projects I otherwise admire. Like Haiku and perhaps this FreeNOS too.

I won't go into details why, but perhaps I'll summarize that for kernel development, C++ offers too much with too little gain.

For an interested reader, the internet is full of debates where some of the most prominent kernel developers of today debate the usage of C++ in kernels. Interesting reading.


Unfortunately I find that the debates that do occur descend into nothing more than Micro-kernel versus monolithic, RISC versus CISC etc. where technology fundamentalism rages rampant when the reality is that a combination is more in tune with what is required. What ever the case maybe I guess there are attempts to find the holy grail of languages - the language that can slice, dice, a salad topping and a floor polish all in one.

I tend to be out of step in that I still prefer the idea of a language that has a niche and does that niche incredibly well instead of having a general purpose language that is either an attempt to be everything to everyone that collapses under its own weight or worse no one is happy because it tries to do everything but ends up doing it all half assed.

Reply Score: 2

RE[5]: C++
by strcpy on Sat 11th Jul 2009 13:27 UTC in reply to "RE[4]: C++"
strcpy Member since:
2009-05-20


I tend to be out of step in that I still prefer the idea of a language that has a niche and does that niche incredibly well instead of having a general purpose language that is either an attempt to be everything to everyone that collapses under its own weight or worse no one is happy because it tries to do everything but ends up doing it all half assed.


Well said.

And then breaking this fine sentence into two parts that highlight my personal opinion:


I tend to be out of step in that I still prefer the idea of a language that has a niche and does that niche incredibly well


C.


instead of having a general purpose language that is either an attempt to be everything to everyone that collapses under its own weight or worse no one is happy because it tries to do everything but ends up doing it all half assed.


C++.

Reply Score: 2

RE[3]: C++
by cb_osn on Sun 12th Jul 2009 10:01 UTC in reply to "RE[2]: C++"
cb_osn Member since:
2006-02-26

One of the reasons I have heard (this isn't my opinion btw - so any idiots out there who want to moderate me down claiming to me by opinion - jump off a cliff head first) are when projects become large C++ apparently has a habit of becoming rather unreadable and problematic. Personally I think that reason is more born out of a refusal by some to learn C++ but I could be wrong.

Language flame wars aside, there is really one simple technical reason why C is almost always chosen over C++ for kernel development.

At the kernel level, you're running on the bare metal and you have to provide all functionality from scratch. The features of C++ depend heavily on a runtime to handle things like RTTI, exceptions, global/static initialization, memory allocation and constructors/destructors, among other things. So in order to build a kernel in C++ and take advantage of its features, you have to hoist a whole runtime into the kernel at the earliest moments of the boot process. You can use C++ without those features, but once you strip out enough of them, you're basically left with C anyway. So the path of least resistance is to start with C, since it is still mostly functional without the runtime, and implement the features that you need as you go.

To use Linux as an example: the kernel does not link to glibc and the C standard library is not available other than specific functions which were implemented internally in the kernel.

Reply Score: 1

RE[4]: C++
by yorthen on Sun 12th Jul 2009 11:09 UTC in reply to "RE[3]: C++"
yorthen Member since:
2005-07-06


At the kernel level, you're running on the bare metal and you have to provide all functionality from scratch. The features of C++ depend heavily on a runtime to handle things like RTTI, exceptions, global/static initialization, memory allocation and constructors/destructors, among other things.


Except of course that only RTTI and exceptions requires the runtime, constructors and destructors are just syntactic sugar for function calls at the right places. Global/static initialisation is also compile-time, memory allocation you have to manage in every OS and using C++ does not make it any simpler nor harder.

No, the real reason is probably that a couple of years ago when the debate started the computers were quite slow and memory quite expensive (compared to today's computers) and C++ compilers were quite bad. You simply could not afford the less optimal code that the C++ compilers generated. Today that is not a problem, a lot of time, money, and effort has gone into making efficient C++ compilers and I would say that most energy is put on making C++ compile well and not C (remember that both Intel and MS sells C++ compilers, even though they can compile C too (well, at least Intel's can)).

Reply Score: 2

RE[2]: C++
by SpaceDudeAlien on Sat 11th Jul 2009 11:43 UTC in reply to "RE: C++"
SpaceDudeAlien Member since:
2008-03-27

Developers in general (and the Great Mister L in particular) strongly believe that one cannot develop efficiently in C++.

Unfortunate indeed because that C++ "disadvantage" is yet to be proven and only exists in theory. Yes, sure, there is some internal language-overhead involved, however that may be dwarfed compared to the inefficiencies introduced when adding additional layers of features down the road while using straight-up C... At least C++ gives you means to evolve any piece of code very, very nicely w/o the need to re-write everything.

But that's just my opinion - I'm no Kernel developer, at least not yet.

So long.

Reply Score: 3

RE[2]: C++
by vivainio on Sat 11th Jul 2009 12:13 UTC in reply to "RE: C++"
vivainio Member since:
2008-12-26

I really can't believe speed is an issue. I think it's an flawed excuse for conservative programmers.


You can "hand tune" C code to be faster, because C compilers are less smart (and hence more predictable and mature). There is also lots of things C++ code does in the background (unless you are careful to avoid it) that you have to do manually in C (hell, the fact that you need to do everything manually in C is what makes it a bad app development language).

Reply Score: 3

RE[3]: C++
by msieweke on Sun 12th Jul 2009 17:53 UTC in reply to "RE[2]: C++"
msieweke Member since:
2006-07-18

The eCos kernel is written in C++, but they had to take care to use only a safe subset. Everything is compiled without exceptions or RTTI. Still, they had to implement a C++ run-time in the kernel to get static constructors to run at the right time and in the right order. C++ does complicate things.

Microsoft has a good article on what to be aware of when writing kernel code in C++: http://www.microsoft.com/whdc/driver/kernel/KMcode.mspx . Most of these concerns don't affect eCos because eCos doesn't use the MMU.

Reply Score: 2

***->->
by aacs on Sat 11th Jul 2009 11:41 UTC
aacs
Member since:
2008-12-13

Useful project. Only if they decided on using either tabs or spaces, preferably the latter, as now they're used randomly (given readability is priority #1).

Reply Score: 1

Comment by marcp
by marcp on Sat 11th Jul 2009 14:14 UTC
marcp
Member since:
2007-11-23

Nice project indeed, although it looks like a linux-fork.

Reply Score: 1

Mark Williamson
Member since:
2005-07-06

L4::Pistachio is another microkernel written in C++. http://l4ka.org/projects/pistachio/

Although L4 looks, from the original papers, like a really promising and practical microkernel I'm generally a bit hazy on what all the different implementations of L4 nowadays have to offer relative to each other.

Reply Score: 3

FreeNOS boot?
by AndrewZ on Mon 13th Jul 2009 15:52 UTC
AndrewZ
Member since:
2005-11-15

I looked at the FreeNOS site and I did not see any provision for booting on a PC, only virtual environments. Is this the case? Are there plans for a PC bare metal boot?

Reply Score: 1