Page 1 of 1
C, C++, and Operating Systems
PostPosted: Sat Sep 17, 2011 8:59 pm
by Arya Raiin
Well, after getting frustrated with the operating systems that are on the market today I've decided that I'm going to attempt to build my own OS. If I do, I'm going to need to learn C and C++. I know some of the basics but I need a good tutorial.
I have a good handle on HTML and CSS, so I am familiar with computer languages. I catch on quick, so a book that covered a lot of material would be nice.
Oh, and yes I know I probably won't be able to build a stable OS on my own. I will be assembling a small team once I learn C and C++.
Any tips, comments, and recommendations are appreciated!
PostPosted: Sun Sep 18, 2011 7:17 am
by Warrior4Christ
Not to dampen your enthusiasm, but making an OS is a very large and complex task... HTML/CSS are what would be considered very high-level scripting languages, which are very different from C, which is very low-level. But C/C++ is a very useful language to learn, so it's great that you're keen!
There's actually many complex parts to an OS that aren't immediately obvious - multitasking, process handling, device drivers, security, memory management, file system, as well as the user interface. Some example OS projects are:
MINIX 3 (
http://www.minix3.org/) - free small UNIX OS used to teach how OSes work.
ReactOS (
http://www.reactos.org/en/index.html) - open source implementation of Windows XP - interesting project.
Another good starting point is GCC, the most popular C/C++ compiler, and free (
http://gcc.gnu.org/).
It works well with Linux, if you've got that installed, or on Windows use the Cygwin UNIX emulator (
http://www.cygwin.com/) and choose the gcc4 development packages.
And read lots of books - but I can't particularly recommend any beginner books or sites. Just search for them I guess. And learn about operating systems and C at university, because that helps a lot. I think C and C++ are different enough languages that they're both worth learning as their own language. It may be helpful to learn a bit of C first, then move on to C++ (but you'll still learn more about C as you go).
Good luck!
PostPosted: Sun Sep 18, 2011 9:55 am
by TheMewster
1. I thought ReactOS was illegal.
2. I've actually wanted to make an OS but I've never gotten around to learning programing. I can make text bold, italic, and underlined, I might be able to make a paragraph, but that is likely it. I have a lot of ideas though so PM me!
PostPosted: Sun Sep 18, 2011 6:44 pm
by Furen
C++ is totally different than that mew, for an example
- Code: Select all
[color="Lime"]//Title of program[/color]
[color="Sienna"]#include "stdafx.h"[/color]
main()
string varName;
varName = "yourname"
cout << "What is your name?" << endl;
cin >> varName;
cout << "Hello " << varName << "!";
it gets more complicated, (and it may not be perfect, I haven't done this for a few months) but that's a basic structure of what it would look like.
PostPosted: Sun Sep 18, 2011 7:06 pm
by Arya Raiin
@Ren Ah, it's structure is fairly close of PHP! That could be fun then!Oh
Yea... can't really go to college at the moment. I'm only a sophomore... XD
I have quite a few talented people available to me for making this. And I know, this is a huge project. It will probably take at least three years to finish. Probably way more. I'm also not sure if I would leave it as an open source, or turn it into an actual software package for people to buy. It'll take more time and an actual team for me to decide on things.
@Mew Sure, I'll shoot you a message!
Waiting for Mith to post...
PostPosted: Mon Sep 19, 2011 12:03 am
by Dante
I think you'd have an easier time jumping onto an existing operating system project like one of the Linux builds. Maybe you could help make the next version of Ubuntu or the like if you learn more code. Alternatively, if you got rather good, you could just go work for Microsoft too (nothing wrong with that).
However, building yourself an entire operating system from scratch would be... well, even the most basic of operating systems would be a hideous task to create, even with a small team of 1337 programmers. However, if you end up studying operating systems this much, you'll likely find that you can 'fix' the broken ones you don't like.
Still, I think, as other users have pointed out, that there is a BIG jump between html and C++. HTML and CSS are nice starts, it's where I began and it provides a great intro to the basics, like debugging and such - but languages like C and C++ are... vastly different. On the last project I was building for a friend on Cybernations (still being debugged) the closest thing I built to HTML was XAML, an XML style for building Silverlight and WPF applications for C#.NET programs.
http://www.tensor-industries.com/MyPrograms/TestPage.html
When finished, it looks pretty cool right? However, it took about 20-25 pages of code just to build it, half of which was coded in XAML, the other half in C#.NET. If I built it in something like C++ which lacks the robust API services that C#.NET has out of the box, there is no telling how many pages I would have to code to make that. I think it's safe to say, I'd have to code a LOT. Then if you consider a whole operating system... you're suddenly talking about writing, debugging and managing MASSIVE sets of code. That's why we have development 'teams' and for most projects and they take forever to come out.
When you're talking about competing with Microsoft - you have a long ways to go. They've basically closed the window of opportunity on operating systems and have very few potential competitors. Still, I lived through Window ME and 98, you youngins have nothing to complain about with your new-fangled shiny desktops and what not in win 7 or even Vista (Oh what I would have given to do a simple system restore to eliminate malware- back then they just laughed at stuff like that).
PostPosted: Mon Sep 19, 2011 4:30 am
by Warrior4Christ
TheMewster (post: 1505309) wrote:1. I thought ReactOS was illegal.
2. I've actually wanted to make an OS but I've never gotten around to learning programing. I can make text bold, italic, and underlined, I might be able to make a paragraph, but that is likely it. I have a lot of ideas though so PM me!
I thought ReactOS was a "clean room implementation":
http://en.wikipedia.org/wiki/ReactOS
An extensive code audit is in place to protect against legal problems, such that implementation of the Windows API is only done by means of a complete clean room reverse engineering process.
Furen, close, but you forgot the curly braces and return type of main:
[code]
[color="Lime"]//Title of program[/color]
[color="Sienna"]#include "stdafx.h"[/color]
int main()
{
string varName]
(And what's stdafx.h? Shouldn't it be iostream?)
Oh yeah, here's an online C++ tutorial which may be good:
http://www.cplusplus.com/doc/tutorial/
I frequently use the reference section here too:
http://www.cplusplus.com/reference/
Learn about operating systems from the author of MINIX with this book (and MINIX is a mere 6000 lines of code btw, Dante):
http://www.amazon.com/Operating-Systems-Design-Implementation-3rd/dp/0131429388/ref=dp_ob_title_bk
So what are the key features of your OS that aren't in current OSes?
I wanted to make an OS when I was in school too... called Doors. And it would have an add-on pack called Doors Plus ("Doors Plus - no fuss" - not at all copied from an advertising jingle). I didn't actually get around to implementing it though.
PostPosted: Mon Sep 19, 2011 10:31 am
by Dante
Only 6000 lines of code? That's quite impressive, I figured it would require quite a bit more then that. That's still a ton of coding though
.
PostPosted: Mon Sep 19, 2011 10:40 am
by blkmage
Well, that's just the kernel, right? And MINIX is a microkernel, so of course it's going to be tiny in comparison to everything else that's currently in use.
PostPosted: Mon Sep 19, 2011 1:16 pm
by Furen
Warrior4Christ (post: 1505551) wrote:Furen, close, but you forgot the curly braces and return type of main:
[code]
[color="Lime"]//Title of program[/color]
[color="Sienna"]#include "stdafx.h"[/color]
int main()
{
string varName]
(And what's stdafx.h? Shouldn't it be iostream?)
Ach, I forgot the curly brackets... also, my school had some weird thing that wouldn't let our computers run unless I wrote in stdafx.h but I could run it without iostream, though I usually had it in and everything
Thinking on it though, I forgot to import string.h too
PostPosted: Tue Sep 20, 2011 6:22 am
by Warrior4Christ
blkmage (post: 1505594) wrote:Well, that's just the kernel, right? And MINIX is a microkernel, so of course it's going to be tiny in comparison to everything else that's currently in use.
Indeed. The complete source code is printed as an appendix in the book....
Furen (post: 1505622) wrote:Ach, I forgot the curly brackets... also, my school had some weird thing that wouldn't let our computers run unless I wrote in stdafx.h but I could run it without iostream, though I usually had it in and everything
Thinking on it though, I forgot to import string.h too
Ah. stdafx.h isn't standard C++. And string.h is actually for C string functions - you'd be after <string> instead.
If we're being pedantic:
You need std:: scoping on cout, cin, end, string.
varName = "yourname" is unnecessary and can be removed.
The second cout should probably have an endl too.
Of course add #includes for <iostream> and <string>.
Then it's all good.
Another tip is to use the latest compiler you can, which supports the latest language standard (and enable it). Use the C++11 standard (which just came out a few months ago) and the C99 standard. The newer language features make it nicer to use.
PostPosted: Wed Sep 21, 2011 2:12 am
by Kaligraphic
I would like to know what frustrations would drive you to such lengths as to devote the kind of time and resources you would need to write a new operating system.
Frankly, if you don't know C or C++, the frustrations that you feel with your OS are more likely to be solved with a different window manager or shell replacement than by writing a new operating system.
PostPosted: Wed Sep 21, 2011 6:32 pm
by ABlipinTime
I'm in agreement with Kaligraphic. Though I don't like what's been done with current OS's, I think it would be much easier to start with the Linux kernel.
Normally, you would find the Linux kernel's here: kernel.org
But, if you've been reading slashdot.org, you might have noticed that the website was recently hacked and the site managers have blocked traffic for awhile. You can still find the Linux kernel elsewhere.
Incidentally, I've considered using Ubuntu, and even tried it out. My biggest problem with it is that it's impossible to install anything I find on the internet. (yes, I download sourcecode)
PostPosted: Thu Sep 22, 2011 4:39 pm
by TheMewster
Ubuntu is impossible for me to install on my Windows XP Home Edition. It just doesn't work, no matter what methods I try; or the uploading to cd methods dorm work. I decided to just accept the fact that God obviously does NOT want me to have it (especially since I wanted it for my pleasure not His) and decided to try to just be thankful for my old XP.
PostPosted: Thu Sep 22, 2011 10:35 pm
by Dante
I may be wrong, but I don't think you can 'install' Unbuntu on Windows XP. It's essentially a separate operating system and if you don't do it right, it could essentially make Win XP inoperable.
To get Unbuntu working, you have to burn the .iso file to a cd, then restart your computer. Before it loads, get into the BIOS screen and change the order of the drive loading order. You want to make sure that you load from the CD-Rom tray first, not the hard drive.
Then, after making this change, you have to place the CD in the drive and hopefully it will spin on the next restart. The computer should then try to load from the CD which should bring up the Unbuntu installation screen. Linux installations are far less user friendly then Win XP though - so be a bit wary on this. There are ways however to do a duel Win XP/Unbuntu install - but I've never tried this. Also note that it has plenty of weird formatting options for your hard drive. Once again, I don't remember which one worked for me.
Eventually though, I did get it to work inside so my mother can surf the net without having to worry about viruses too much. Sadly, the machine still isn't perfect - it displays a pair of green lines across the monitor (something gone wrong in the graphics component of Unbuntu) and it does occasionally freeze on her. But for a 9-10 year old computer, it isn't half bad.
PostPosted: Fri Sep 23, 2011 12:54 am
by Kaligraphic
You... kind of can, but I don't think that's what Mew was talking about. Still, when dealing with technology, rather than saying "God doesn't want me to have this," a more correct approach would be "I may not be doing this correctly. I should do more research and/or ask somebody."
Mew, I'd suggest that you have someone who knows what they're doing help you, especially if it's your first time installing Linux.
PostPosted: Fri Sep 23, 2011 6:55 am
by blkmage
Dante (post: 1506294) wrote:Eventually though, I did get it to work inside so my mother can surf the net without having to worry about viruses too much. Sadly, the machine still isn't perfect - it displays a pair of green lines across the monitor (something gone wrong in the graphics component of Unbuntu) and it does occasionally freeze on her. But for a 9-10 year old computer, it isn't half bad.
There's nothing "wrong" with Ubuntu. It's just that your graphics card or monitor probably doesn't have perfectly compatible Linux drivers, which is very likely if the hardware is as old as you say it is. You have to remember that not everyone is willing to invest time into developing Linux drivers for their hardware, which was especially true back in the early 2000s.
PostPosted: Fri Sep 23, 2011 11:54 am
by Davidizer13
To install Linux for the C/Linux class I took a while back, the professor had us use a program called VirtualBox, which made a virtual machine where we could install Ubuntu. It made a partition of RAM and HD space for the program for Linux (or BSD, or Win XP, or whatever you wanted to put in there) to run in, which doesn't otherwise interact with the Windows/OS X install you have; think of it as a new computer on your computer. Unfortunately, this means you'll be splitting your total available resources between the two OSes. Since the computer I was running it on was pretty old, slow and packed full of stuff I thought I'd need, I couldn't allocate much space for it, but on a newer machine, it'd run a lot better, especially considering how cheap Ubuntu is to run.
Eventually, working with Linux didn't convert me, but I did like the power it gave you through the command line; the real trick is knowing the commands. The man command is your friend in that, so use it often!
As for making your own OS, Arya, I'd start a little smaller before taking all that on. Rather than making a whole new one from scratch, start by writing programs and tools that modify or work with an existing open-source OS, while pulling the OS apart to see how it works and trying to go one better on what's already been done.
PostPosted: Fri Sep 23, 2011 3:34 pm
by ABlipinTime
I used PenDrive Linux to install Ubuntu on my computer. It seemed to work fine, though ironically I did discover that only the intel x86 version would work with my AMD processor. lol
PostPosted: Fri Sep 23, 2011 9:36 pm
by Warrior4Christ
ABlipinTime (post: 1506437) wrote:I used PenDrive Linux to install Ubuntu on my computer. It seemed to work fine, though ironically I did discover that only the intel x86 version would work with my AMD processor. lol
"Intel x86" (32-bit) and "AMD64" (64-bit) are the processor architectures (so yes, Intel and AMD both make x86 and AMD64 processors). I guess your processor is just 32-bit then (it is old?).
PostPosted: Mon Sep 26, 2011 2:50 pm
by ABlipinTime
Warrior4Christ (post: 1506524) wrote:"Intel x86" (32-bit) and "AMD64" (64-bit) are the processor architectures (so yes, Intel and AMD both make x86 and AMD64 processors). I guess your processor is just 32-bit then (it is old?).
Shows what I know about architectures. shucks. yes, my processor is 32 bit
PostPosted: Wed Sep 28, 2011 2:03 pm
by TheMewster
Kaligraphic (post: 1506306) wrote:You... kind of can, but I don't think that's what Mew was talking about. Still, when dealing with technology, rather than saying "God doesn't want me to have this," a more correct approach would be "I may not be doing this correctly. I should do more research and/or ask somebody."
Mew, I'd suggest that you have someone who knows what they're doing help you, especially if it's your first time installing Linux.
This IS my first time installing Linux. Now should I try this again? It wouldn't go to my blank CD, so obviously there must be divine intervention. I need to be careful with this especially because if it is God intervening I must respect that. Then again if I try again it wouldn't work period if it is divine intervention. What is the BIOS screen? I would get help but fat chance there's be someone in my small town who knows what Linux IS and even then we can't have them over because of the dogs.
ABlipinTime (post: 1506437) wrote:I used PenDrive Linux to install Ubuntu on my computer. It seemed to work fine, though ironically I did discover that only the intel x86 version would work with my AMD processor. lol
Pendrive Linux got Ubuntu on my 500 gig external hard drive (what you think I'm blowing my money on a flash drive when I already have this?) And anyway God bless and help!!!
PostPosted: Wed Sep 28, 2011 2:49 pm
by Davidizer13
TheMewster (post: 1507296) wrote:This IS my first time installing Linux. Now should I try this again? It wouldn't go to my blank CD, so obviously there must be divine intervention. I need to be careful with this especially because if it is God intervening I must respect that. Then again if I try again it wouldn't work period if it is divine intervention.
Since I have serious doubts about divine intervention in this case, let me see if I can remember how to do this...
1. Get an
.iso file for Ubuntu, if you don't have it already. It's free! Go ahead and skip that part about burning it to a CD/thumb drive. [Unless you want to, in which case you need to get some software that can burn an .iso to a blank CD (MagicDisc works well, plus, it's free). Burn that sucker and use it as a backup, just in case!. This step isn't necessary - you're able to boot your virtual machine directly from the Ubuntu ISO file.]
2. Get
VirtualBox. It's also free.
3. Make a new virtual machine on VirtualBox with enough RAM and hard drive space you think you'd need to mess around with Linux. 512 MB RAM and ~10 GB HD should be more than enough, but keep in mind that by giving it to the virtual machine, your main machine won't be able to use it when the virtual one is on your system! Set your virtual machine to boot from the Ubuntu .iso file. (You did put it where you could find it, didn't you?)
4. Start up the virtual machine. Ubuntu should start installing itself, and IIRC, even updates itself if you've got an Internet connection available. Follow the prompts and set it up the way you want it.
5. WINNA WINNA CHIKKIN DINNA!!!!~!~!~!!!!!~!11 Whenever you want to run Linux in the future, start up VirtualBox, fire up the virtual machine, and off you go!
6. Learn Linux, become a leet haxxor3r, win friends, influence people, drive around town in expensive cars with [s]beautiful women[/s] handsome men at your side!
Now, when this is all over, you won't have a machine dedicated to just Linux, if that's what you really wanted to do. It'll just be a virtual computer so that you can run Linux without having to really mess with your main system too much. Still, it'll be enough that you can learn the OS and find your way around.
TheMewster wrote:What is the BIOS screen?
It's that gobbedlygook that shows up on your screen when you turn on your computer, before your OS starts up]Pendrive Linux got Ubuntu on my 500 gig external hard drive (what you think I'm blowing my money on a flash drive when I already have this?) And anyway God bless and help!!![/QUOTE]
The thing with external hard drives is that they're limited by the connection speed between the drive and the computer. In an internal HD, you've got this big thick cable that's connecting between components, so that's really not a problem but with an external, you're usually going through a USB cable. Because of that, it's probably going to run a bit slower, possibly not enough to run something as demanding as an OS from it. External HDs are great for backing up data, but because of that limit, it's better if you have your programs on your internal drive. I'm not a computer science major or anything, so I don't think I've got everything right, so you should probably fact-check me on all that, but that's what a forum's for, right?
PostPosted: Thu Sep 29, 2011 5:21 pm
by TheMewster
Good idea! Do you think I can store my VirtualBox stuff on my external HD? That's pretty much the only way I'd have computer space for Linux, lol. Thanks so much and God bless you!
PostPosted: Thu Sep 29, 2011 7:49 pm
by shooraijin
You can, but depending on the interface, you might suffer some performance issues. If you must have it external, try to have it on an eSATA drive at least.
PostPosted: Sun Oct 02, 2011 5:47 am
by TheMewster
Actually, never mind on Ubuntu. I've decided after today NOT to get it for Spiritual reasons. If you need them PM me for them, as they would make me delve into theology discussion if I post them here.
And Arya Raiin, I admit I was selfish and hijacked your thread. You may have it back. I admit I really don't feel sorry, but I do not want to do this again and it was not a very good idea to hijack this thread.
PostPosted: Tue Oct 04, 2011 11:42 am
by Dante
Edited. I think I understand this better now. sorry for the seemingly useless post.