Page 1 of 1

is it possible to use Boost for OS development?

Posted: Sun Nov 27, 2011 1:25 pm
by Coderx
hello all .
i 've read the wiki that with cross-compiling it is possible to have the full C++ Standard Library available for OS development , but i couldn't find any information stating or hinting to the possibility of using boost libraries (or possibly the likes ?) for Os development .
has anyone done anything about this in any form of it ?
i would be very happy and also will appreciate any kind of help on finding more about this matter .
Thank you in advance

Re: is it possible to use Boost for OS development?

Posted: Sun Nov 27, 2011 2:14 pm
by Love4Boobies
You can't really use the whole standard library nor the whole of Boost for kernel development without impleneting the underlying functionality (e.g., how would you deal with files without a file system; sockets without a network stack; or threads without a scheduler?)---and significant part of them don't even make sense in the context of a kernel. Although some may disagree with me, my opinion is that kernels should only use the freestanding library---that's what it was designed for; the full (hosted) library is for user applications to use.

Btw, as of this year, a big part of Boost is officially part of C++, although it will take a while for compile vendors to implement the whole functionality of C++11.

Re: is it possible to use Boost for OS development?

Posted: Sun Nov 27, 2011 2:54 pm
by Solar
Some parts of Boost are clearly inappropriate for kernel work. But you surly didn't think about Asio or Thread, did you?

Other parts of Boost should be usable: Tuple, Array, stuff like that.

Then again, Boost has a reputation for blowing up compile times and executable sizes if not used with caution.

So, the question is:

Do you want to use Boost because you know exactly what you're doing and consider the productivity increase to be worth the effort - or do you want to use Boost because you always used it in userspace and don't really feel up to implementing similar functionality by yourself?

If it's the former, by all means go for it (and write a Wiki article about which parts of Boost can be used in this way). If it's the latter, you better stay away from it...

Re: is it possible to use Boost for OS development?

Posted: Mon Nov 28, 2011 12:22 am
by Coderx
thank you very much guys , i really appreciate it
the reason i went for boost libraries is that i wanted to provided a rich development library for my os ( for further development) , and thought maybe just like C++ standard library, there is a way for it .
im aware that threads and system files are exclusively OS dependent and for those to work i need to implement the corresponding bare bones in my os first , i was more after those sections which boost made it more user friendly for newbie c++ users , stuff such as arrays , foreach , and the likes ( which also are available in standard library , but their use in boost are way more elegant ) .

having all of these said for example for developing a graphics library, all burden is on my right?
and by the way , which part of C++ standard library is not useable in os development ( except threading , dates and system commands )?

Re: is it possible to use Boost for OS development?

Posted: Mon Nov 28, 2011 2:42 am
by Solar
Coderx wrote:...and by the way , which part of C++ standard library is not useable in os development ( except threading , dates and system commands )?
Everything is "usable" in OS development - provided that all dependencies are met.

If you write your library code yourself, you will immediately recognize what those dependencies are. If you use third-party code, there are two things to take into account:
  • Which low-level functions does the library require to function? Check the library documentation, e.g. for Newlib or PDCLib.
  • What is the speed / memory consumption penalty you are paying? Especially with C++, harmless-looking code can have significant impact on code size, memory use and runtime performance.
Bottom line, and to invert an old Jedi saying: Try. There is no "do" or "do not". 8)

Re: is it possible to use Boost for OS development?

Posted: Mon Nov 28, 2011 4:08 am
by OSwhatever
The boost intrusive library can be used for kernel development. All of them are written in meta-programming which means there are no dependencies to libraries. You have to configure boost though so that it understands there is no underlying OS but it can be done. Intrusive library gives you things like lists, trees, sets, hash tables.

I've tried it and it works. There are some concerns that makes me unwilling to include it though. Meta-programming adds a lot of time to the compile time, boost is very slow to compile. The intrusive library is quite optimized but the actual core algorithms are standard which means it will not use any HW support for concurrent programming. Might not be much of an issue now but it might be in the future. If you make your own you can easily replace the core algorithm. Boost use ordinary constructors and I've found out it doesn't always fit that well during early boot.

Re: is it possible to use Boost for OS development?

Posted: Tue Nov 29, 2011 8:37 am
by Coderx
Thank you verymuch guys , your information were really useful to me .
I'm considered a newbie programmer (although i've been coding since 2007 , but they were mostly my hobbies ) so im ignorant of the how tos on getting boost library to work with my os at this stage ,
i have already created an OS , in pure asm , both boatloader and the kernel , in my kernel i added support for fat12 ( both saving and loading files ) and thats all .
i though about expanding this ,so thought its a good idea to code an OS in C++ rather than assembly , ( i had so much problems because of jumps , callbacks and maintaining code in asm) , so that by using classes i can add different functionalities without getting myself too confused .
i think i'll try to use the STL first and then if i succeeded i make a new thread for the possible solutions :)
by the way do you recommend C over C++ or im good with c++ ? does using classes impose alot of overhead in OS development ?
i'll be thankful if anyone could answer these questions too
again Thank you for your time and help :)

Re: is it possible to use Boost for OS development?

Posted: Tue Nov 29, 2011 8:45 am
by Solar
The less experience you have, the simpler the things you should try.

Coding your OS kernel in C is simpler than C++.

That wouldn't be enough for me to discourage you from using C++. But I do discourage you - who admitted to being new to this - from trying to fiddle with the STL or Boost. Neither are necessary, and I could picture neither is helpful in the early stages of development. At least not until you have memory management and complete C++ runtime support up and running.

Re: is it possible to use Boost for OS development?

Posted: Tue Nov 29, 2011 12:48 pm
by Coderx
thanks , but what about c ? is it not just like c++ in terms of standard libraries ?and the effort needed for setting the environment for our os development? i mean which part of working with C++ is that troublesome that made you recommend C over C++ ?
by the way i am more familiar with C++ than C , had experience with both boost and STL , i'm not at the expert level ! ( im not confident enough when it comes to OS and Optimized code and elegant design and etc , that's why i call myself newbie )
im asking because i trust you guys and believe you are professionals in the field and know both C and C++ , so you can give good advice on this matter .
i would be very pleased to be guided and i appreciate it indeed :)

Re: is it possible to use Boost for OS development?

Posted: Tue Nov 29, 2011 2:01 pm
by AJ
Hi,
i mean which part of working with C++ is that troublesome that made you recommend C over C++ ?
Take a look at C++. If you want any of the C++ features that require runtime support, you need to do a lot of work to get it up and running. That's not to say that the hard work won't pay off in the long term, particularly if you are more familiar with C++ in the first place. Also, with C++ you also need to be a little careful about some of the stuff that would happen automagically in a hosted environment. For example, you need to be particularly cautious about features / constructors that use dynamic memory allocation until your heap is properly initialised.

A lot of OSDev involves wrestling with order of implementation for interdependancies - this is perhaps more pronounced with something like C++ when you also have to decide which order to implement your runtime support.

Cheers,
Adam

Re: is it possible to use Boost for OS development?

Posted: Wed Nov 30, 2011 6:29 am
by Coderx
Thank you Adam :)
one more question , do i have complete support for classes and inheritance in C++ ? i mean if the libraries are not available that much , its not that serious to me at this level , but using classes are indeed , so do i have any limitation in using the Object oriented aspects of C++ for OS development ?
thank you in advance :)

Re: is it possible to use Boost for OS development?

Posted: Wed Nov 30, 2011 6:38 am
by Combuster
Classes do work, as they are little more than syntactic candy for a typedef struct. Passing types as an argument generally does not so you won't get anything beyond static typing.

Re: is it possible to use Boost for OS development?

Posted: Thu Dec 01, 2011 2:55 am
by Coderx
Thank you very much guys :)