How many C++ kernels?

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Twitch
Member
Member
Posts: 40
Joined: Mon Jun 04, 2007 6:29 pm

How many C++ kernels?

Post by Twitch »

Just out of curiosity how many people here have made there kernel in C++ instead of C?And if so how did it change the design of the kernel aposed to a C kernel?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

I have a c++ kernel which I have converted from my previous C kernel.

The memory management is pretty much C compiled with gpp. For the rest, I have switched over to classes, including a few global classes, such as 'Debug', 'Interrupt', 'DeviceManager'.

My hope is that when I am editing code and adding bits and pieces to the kernel, c++ will make a neater job of it.

The main reason I actually prefer my c++ kernel over my C kernel is that I like classes. They seem to make everything so much neater [ducksandruns]. *This is purely personal preference*[raisesheadoverparapet].

I have often heard the sentence 'C++ is not suitable for OS dev'. I have yet to find why that is. Once you have written some basic runtime support, there's no reason why C++ should be any less suitable for OS dev than C [ducksagain].

Oh - if you are interested in c++ kernels, I wouldn't start by reading any of my source code. Although my c++ kernel is (IMHO) less messy than my C kernel, it still needs a lot of work from the point of view of tree organisation, some standardisation of function names etc...

Cheers,
Adam
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

I have to say, I agree with AJ.

Although, ATM I'm in the middle of converting from C to C++ so I'm not adding in classes unless they can really be used (my CLinkedList template class comes to mind).

I learnt C++ first, and find classes a natural way of creating a modular kernel. I'm going to get flamed for saying this, but it's so much easier to write linked list code in C++ than it is in C. In C you have to write complex wrappers and cross your fingers (while manipulating large amounts of data). As I said earlier, in C++ I use one template class everywhere I need a linked list (CLinkedList). It saves so much time and means I don't have to worry about dud implementations.

I still think writing a kernel in C is a good learning experience, and I wrote mine in C to start with. But I prefer the OOP features, so I use C++ now.
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

I started out with c and then quickly switched to c++ for a lot of the more complex stuff. I just love classes, especially virtual ones. Most of the really low level stuff like paging, memory management, and task switching is in c, but almost everything else is in c++ ie. the screen, file access and disk access are all in c++.
jtlb
Member
Member
Posts: 29
Joined: Sat May 12, 2007 8:24 am

Post by jtlb »

i am also writing my kernel in c++ becaus i find it "nicer" than C it's easier too.
Of course my memory manager is entirely writen in C but compiled by g++. no .c file in my code.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

I think it'd be pretty cool to make one in C++, though I just haven't...btw, anyone ever seen like a framework C++ kernel, that doesn't have anything, but comes with an OS freidnly crt, and what ever else would be needed?
Twitch
Member
Member
Posts: 40
Joined: Mon Jun 04, 2007 6:29 pm

Post by Twitch »

Thank you for all the the input :D
That put a lot of stuff I have heard about C++ kernels to rest.Some of the things I have read from the linux kernel developers and linus makes it seem like hell to make it in C++.And one thing I want AJ to ask is how much trouble is getting runtime support up on your OS?
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

Twitch wrote:Thank you for all the the input :D
That put a lot of stuff I have heard about C++ kernels to rest.Some of the things I have read from the linux kernel developers and linus makes it seem like hell to make it in C++.And one thing I want to ask is how much trouble is getting runtime support up on your OS?
It's matter of preference. None is better than the other.

To me it's as if C is pure unaltered greatness, something like just plain tea.
Then, you have C++, which is tea with sugar, honey, milk, and other flavorings.

I prefer just plain tea. :)
C8H10N4O2 | #446691 | Trust the nodes.
earlz
Member
Member
Posts: 1546
Joined: Thu Jul 07, 2005 11:00 pm
Contact:

Post by earlz »

And then there is ASM that is like beer...you'll eventually kill yourself with it

my personal preference is Dr. Pepper...the best pop ever..(that's more like what C is, and hten that dieat cherry vanilla kind is C++...though that's not really very true..)
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

Alboin wrote:I prefer just plain tea. :)
Don't you even have milk? I couldn't stand that, would be far too overwhelming. Though i agree it is best without all the other extra's.

I've never been a fan of C++ because the linker support always made it seem really dirty like any amount of programming in it was a quick hack. I prefer to stick to plain old ASM.
Twitch
Member
Member
Posts: 40
Joined: Mon Jun 04, 2007 6:29 pm

Post by Twitch »

hckr83 wrote:And then there is ASM that is like beer...you'll eventually kill yourself with it

my personal preference is Dr. Pepper...the best pop ever..(that's more like what C is, and hten that dieat cherry vanilla kind is C++...though that's not really very true..)
LOL
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Post by Tyler »

hckr83 wrote:And then there is ASM that is like beer...you'll eventually kill yourself with it

my personal preference is Dr. Pepper...the best pop ever..(that's more like what C is, and hten that dieat cherry vanilla kind is C++...though that's not really very true..)
I reserve a word for times like this... a word that the times have driven me to use on about 20 occasions a day as a flip through Music Channels and Kids Viewing on TV... Dumbass

Despite the obvious childlike attitude of saying alcohol is some kind of murderer, which is on that same level as the numerous comments i hear about Marijuana being somekind of mind altering chemical beyond that of the other numerous mind altering chemicals humans intake everyday...

You also seem to be under the impression that Dr. Pepper is good for you. I assure you that beer in the same quantity as an okish amount of Dr Pepper is far better for you physically, mentally and in the sense of causing you to crash and kill someone. I hate to even think about the chemicals in Drinks like that and Coke... hence the reason i live off Water, Tea and the occasinal wine just in case they were right about it being good for your heart.

In conclusion... they are not good for you, also they are far more expensive than tap water.
User avatar
Alboin
Member
Member
Posts: 1466
Joined: Thu Jan 04, 2007 3:29 pm
Location: Noricum and Pannonia

Post by Alboin »

Actually, from what I've read, alcohol in moderation extends your lifespan. Not so much with pop.
C8H10N4O2 | #446691 | Trust the nodes.
User avatar
Kevin McGuire
Member
Member
Posts: 843
Joined: Tue Nov 09, 2004 12:00 am
Location: United States
Contact:

Post by Kevin McGuire »

Tyler wrote:
hckr83 wrote:And then there is ASM that is like beer...you'll eventually kill yourself with it

my personal preference is Dr. Pepper...the best pop ever..(that's more like what C is, and hten that dieat cherry vanilla kind is C++...though that's not really very true..)
I reserve a word for times like this... a word that the times have driven me to use on about 20 occasions a day as a flip through Music Channels and Kids Viewing on TV... Dumbass

Despite the obvious childlike attitude of saying alcohol is some kind of murderer, which is on that same level as the numerous comments i hear about Marijuana being somekind of mind altering chemical beyond that of the other numerous mind altering chemicals humans intake everyday...

You also seem to be under the impression that Dr. Pepper is good for you. I assure you that beer in the same quantity as an okish amount of Dr Pepper is far better for you physically, mentally and in the sense of causing you to crash and kill someone. I hate to even think about the chemicals in Drinks like that and Coke... hence the reason i live off Water, Tea and the occasinal wine just in case they were right about it being good for your heart.

In conclusion... they are not good for you, also they are far more expensive than tap water.
I got a word reserved for you too. I am not allowed to say it.

He was making a analogy:

Writing a entire operating system in assembler
Drinking nothing but beer.
Writing select parts of a operating system in assembler.
Drinking beer occasionally.

Even someone with a moderate amount of intelligence should have noticed that... :?
..<snip>...which is on that same level as the numerous comments i hear about Marijuana being somekind of mind altering chemical beyond that of the other numerous mind altering chemicals humans intake everyday...
I would like for you to smoke a bunch of marijuana then come here in the forums and make a post so I can make fun of you for being a idiot.

Oh... wait. That might be the problem already. Huh?
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Twitch wrote:And one thing I want AJ to ask is how much trouble is getting runtime support up on your OS?
I haven't got the full runtime support up and running yet - only the bits I find useful such as new and delete, support for global and static classes etc...

Have a read of http://www.osdev.org/wiki/C_PlusPlus which is quite helpful for that stuff.

Next on the list are exceptions, try...catch etc, but that is going to need heavier support from the kernel...
Post Reply