Page 1 of 2
Complete Newbie Interested in Writing an OS
Posted: Tue Jul 17, 2007 9:46 pm
by drndrw
Hey guys. I'm drndrw and I, well want to write an operating system. Anyways I'm fairly new to programming (I just know a tiny bit of C# and some PHP) but I want to know what I need to learn and know about to write an operating system. My plan pretty much right now is to finish learning C#, and then to learn C (since C# is a simplified version of C, I think it would be easier to learn) and Assembler after that. Maybe then to learn the basics about writing a Kernel then try writing one. I know my plan is pretty whacked out and it probably won't work, but it might be worth a shot. Anyways, I'm here to ask you guys what I should do to get ready to even consider writing an operating system. I hope you can maybe give me a sane plan to get me going. Thanks
!
Posted: Tue Jul 17, 2007 10:11 pm
by Pyrofan1
since C# is a simplified version of C
no it isn't, C# is what happens when C and Java have children
I want to know what I need to learn and know about to write an operating system
you need to know a lot about computer hardware.
Posted: Tue Jul 17, 2007 10:30 pm
by fbelzile
I have to say that I'm also very new to OS programming. I've done a fair bit of programming within Windows in C/C++.
The first step is to learn these languages. C is an excellent choice of language. Most Operating Systems created by people today are made with this language. People make the mistake of learning C while programming an Operating System. Doing such a thing will cause you lots of confusion for later on when you actually want to make applications. It's a bad habit, don't do it.
Learn C first, and get to know the language, get comfortable with it and its libraries. Try to understand what programming under Windows is about. Learn a bit of the Windows API while you're at it.
Once you know a language, learn about the computer. This is the hardest part. Get to know all the different things about the computer. Learn: How memory works, video memory, interrupts, BIOS, CPU, how the computer boots to its finest details. This is where you think outside the box and where you have to start thinking low level. Windows isn't here to help you.
The first step for creating any OS is to create a boot sector. Look at example boot sectors, learn from them. Understand what they do. Get your hands dirty. Try some sample bootstrap loaders with simple pre-made kernels.
READ, READ, READ
ASK, ASK, ASK
Learn how to print text to the screen both in assembly and in C. Learn how to use the keyboard what the difference is between protected mode (PM) and real mode (RM.) Learn how to write stuff to disks (which I'm trying to learn now hehe)
The wiki on this site is a very good place to start reading. This site helped me a lot on understanding the very basic things of assembly:
http://www.doorknobsoft.com/asm_tutorial.html
Making an OS is not simple. You cant simply go "print ('Hello')" and expect it to do it. You will have to tell the computer what print means, explain to it that you have to write one byte at a time and by moving video address for every character, tell it what color, where the cursor should be and so on... Like I said, very low level.
Don't feel overwhelmed, take it step by step. There is a lot of stuff to learn, if you enjoy it, have fun! Just like me, I have periods where I give up for a while, then I decide to start again, then I give up and start again. Don't force yourself to learn this if you don't want to. You're better off working on another talent... Which makes me wonder why I didn't give up permanently...
Learn C
Posted: Wed Jul 18, 2007 12:16 am
by Mark139
I agree with the statements above. Learn C.
Get a compiler. You have a fair choice of environments available that have good debuggers. Visual C++ express on Win, X-Code on Mac and others for Linux.
I would suggest you learn C by implementing some of the classic "computer science" tasks - Sorting. Linked lists. Tree walking etc. Once you have these you may find you can reuse them in your os
Good luck and enjoy
Posted: Wed Jul 18, 2007 2:16 am
by JamesM
I'm with Mark139. If you're planning to crash-course C, the most important thing is to get to know your way around pointers, seeing as theyre the only real major semantic change between C and every other language (excl. C offshoots, c++, obj-c etc).
So do some tree-walking, implement red-black or AVL trees (self balancing binary search trees, check wikipedia) because they will involve a lot of pointer chopping/changing/modifying/arithmetic. Practice makes perfect!
I REALLY reccommend programming other stuff before an OS. I find it difficult and I've been coding since I was 7, since I was 14 in C. (I'm now 20 and a software engineer at a dynamic binary translator company (Transitive ltd) ).
JamesM
Agree
Posted: Wed Jul 18, 2007 2:44 am
by Mark139
Yes, you really need to have a good grasp of the fundamental data structures and algorithmns - wikipedia has some good articles.
Modern languages (C#, java etc) hide a lot of this stuff from the programmer to make life easier, but you do need to know it especially in OS dev.
I've been programming since I was 15. I'm nearly 42 now - where did the time go
Posted: Wed Jul 18, 2007 9:09 am
by piranha
Did you check out the Wiki?
http://www.osdev.org/wiki/Main_Page
I recommend just learning C now, and forgetting about learning C#. The reason for this is that you probably wont use C# at all during OSDev. You want to learn as much about pointers as possible, and learn how to easily program algorithms that do useful things (sorting, etc...)(I believe this was already said, sorry).
Another good thing to do is to go to
http://osdever.net/. This site has a lot of good documents and tutorials. Also you can go to the Download link and download some of the simple kernels that they have there and (this is what I did) just study them. I printed out the source of some of these and I also printed the Linux source (version 1.0) and went on a week long camping trip and studied them.
Other then that, Read stuff and ask stuff. And good luck.
Posted: Wed Jul 18, 2007 1:24 pm
by drndrw
Thanks guys
. I don't know, but the reason that I want to do C# is because I own Microsoft Visual Studio. I feel that if I do something else, I will have bought it for nothing. I don't want that to happen. So can I use the program as a compiler for C or C++ (not visual)? My C# book cost me two dollars, so I'm not too worried about that
.
Posted: Wed Jul 18, 2007 1:37 pm
by Alboin
drndrw wrote:Thanks guys
. I don't know, but the reason that I want to do C# is because I own Microsoft Visual Studio. I feel that if I do something else, I will have bought it for nothing. I don't want that to happen. So can I use the program as a compiler for C or C++ (not visual)? My C# book cost me two dollars, so I'm not too worried about that
.
Yeah, the
wiki is your friend.
Posted: Wed Jul 18, 2007 2:17 pm
by inflater
Hello,
C is the preffered language for writing OS's,but that does not mean the only language. For example,I was writing a unreal mode OS in Borland Pascal 7 and then I switched to hardcore,the assembly language,which can be really complicated in many ways...
...but you can see the difference between speed and size.
Wait,I was not supposed to scare you away,sorry man...
Regards,
inflater
Posted: Wed Jul 18, 2007 2:18 pm
by inflater
Hello,
C is the preffered language for writing OS's,but that does not mean the only language. For example,I was writing a unreal mode OS in Borland Pascal 7 and then I switched to hardcore,the assembly language,which can be really complicated in many ways...
...but you can see the difference between speed and size.
Wait,I was not supposed to scare you away,sorry man...
Regards,
inflater
Posted: Wed Jul 18, 2007 8:33 pm
by drndrw
I see
. Well I think C++ was kind of scary (I tried it before) so I am kind of shakey on this whole thing myself
.
Posted: Thu Jul 19, 2007 5:54 am
by AJ
Hi,
Just so you don't get scared off, I should say that before attempting an OS I had done little else but Windows programming first. The worst bits about the whole thing was the realisation that:
1. I wasn't going to have 'the new Linux/Windows' OS written complete with GUI in 2 weeks.
2. OMG - no pre-written libraries! You mean I can't just write 'gettickcount()' or 'sleep()' in my boot loader and expect it to work?!
C/C++ isn't so scary. Find a good book. The problem is that if you know C# already, most books start with 'an int is an integer, a char is....' in the first chapter. But you already know that stuff, so it's boring. So you skip to chapter 10. Then you realise that maybe there was some stuff in those first chapters that would have been useful and chapter 10 looks quite tricky - so you are put off C/C++ for life....
Start with little steps and your hobby OS will take off in no time!
Cheers,
Adam
Posted: Thu Jul 19, 2007 1:17 pm
by Dex
Also note, that you can not write your own OS using M$ products
.
Thats right theres a clause in the license, that basic says you can not use it to make OS's.
Now this is in the license for MASM, but i would be suprized if its not in the other M$ products.
Posted: Thu Jul 19, 2007 1:29 pm
by davidv1992
LOL
how do you mean, scared for concurents