Page 1 of 1

Where to start OS Deving?

Posted: Sun Nov 02, 2008 11:23 pm
by rakan
Hello,

I tried searching for previous articles in this forum for how and where to start OS development, but seems like my keywords are too general "where to start os development" :)
I hope that this can be a future reference for anyone like me who would like to start operating systems development.

All i know for now that i have to read a book about operating systems theory and build my knowledge from there. I almost finished this task.
Now i do know some theory such as processes, threads, I/O ... etc. But, what's next to be done?

Maybe this list can be enough?
1) Learn Assembly? for a general purpose OS there are too many architectures, but what asm is good for i383 or i686?
2) Learn C? i already know C... not saying i am pro but let's say i really know the basics.

Hope some professionals will participate and guide us through this edgy path :)

Thanks in advance,
Rakan

Re: Where to start OS Deving?

Posted: Sun Nov 02, 2008 11:45 pm
by babylon2233

Re: Where to start OS Deving?

Posted: Mon Nov 03, 2008 12:27 am
by Solar
rakan wrote:1) Learn Assembly? for a general purpose OS there are too many architectures, but what asm is good for i383 or i686?
2) Learn C? i already know C... not saying i am pro but let's say i really know the basics.
You'll need at least average Assembly skills and a strong understanding of your main language (i.e., C). Experience with large-scale application programming (testing, debugging, version control, modularizing) helps, too.

Personally, I think that "picking things up as you go" is a bad idea in OSDev. I tried it myself, and... let's say it was less than a complete success. ;-) If you want to save yourself some frustration, stay in "user space" until you feel really confident in your abilities. By then, you'll probably have a good, solid idea of where to start, too...

Re: Where to start OS Deving?

Posted: Mon Nov 03, 2008 2:40 am
by rakan
I agree about "picking up things as you go" bit when developing the OS during your learning process.
I am planning to get to a point where i can develop and test things first and then start developing my OS. But as for picking up things, its a natural process :D

Re: Where to start OS Deving?

Posted: Mon Nov 03, 2008 7:12 am
by ~
If you consider that you know a lot of theory, then try to see up to which point you can implement it.

How? Well, try to do little programs that are in reality small snippets that will show yourself how to do those things right.

That's why I prefer to use DOS for this purpose. That's also what I miss from NT/XP and the reason these OS's are rather less useful for me in that aspect. Pure MS-DOS does the job of booting the system and it leaves me in Real Mode. That's about all I need to test my code.

You can use a Win9x installation disk to start up your PC, then press F5 to start at pure MS-DOS at the second menu it presents after selecting "Boot from CD-ROM" (at least works for the Win98 disk), then use a floppy disk to test your code. Using a CD to boot and a disk for tests, at this point, will enable you to use disks even if they develop many bad sectors, until they really are unusable, making your tests faster and cheaper.

Don't think on making a bootable kernel yet unless you want to grasp the idea of how it must be done, and start simple. Just a kernel that does simple things, first without interrupts or other complications like paging.

What I would recommend you would be to make small programs first. The first one could be one to just sets Unreal Mode and enables A20 (it will be really useful in a bootloader, etc.). Then you can do another snippet that enters full protected mode and, either stays in it (locking the PC) or returns to the system after some event (this last one would also be useful if you want to use real mode BIOS functions to properly cut power and shut down your PC, etc.)

The idea is to make these snippets and then, when you want to test a different thing do NOT alter it further, but make a new one to test the new things.

Next, you could add interrupts to snippet(s) to test interrupt, IRQ, PIC and ISR code in a simple way, and then more complex code. It will be useful to isolate problems like say with Interrupts code and solve them promptly.

Then, you could experiment with a Programmable Interrupt Timer driver, a keyboard driver, a driver for legacy DMA, a floppy disk driver and a hard disk one, or a mouse driver, serial and PS/2.

Before you think on doing actual drivers, you could stay better if you start by just making routines for a specific purpose. For example, for reading a sector of a floppy, and then make it into a flexible and backward-compatible-implementable driver call.

Finally, you could try out paging code. Then, a scalable virtual memory manager. Then, multitasking. Then, multithreading.

Of course, you could follow any order to test out features. However, it would be better if you followed a path and a different order that best advances your objectives and makes your learning a comfortable process. Now that's very important to keep you motivated AND productive.

Then, when those snippets (which would have integrated the code you tested to be OK previously), you could start thinking about making a bootable kernel.

If you, at that point, want to experiment with writing a bootloader, do NOT forget that you should be intending to do a simple test, and NOT YET trying to boot a real kernel.

That's what happened to me. I started in November 2004 trying to figure out how to enter raw protected mode with my own code from an assembly book. It used DOS to do it, something I have always done, since it's so easy to test any code in this way (although using COM files, besides it's the simplest, from assembling to running and debugging, only can be 64Kb).

When I started modifying a bootloader from http://osdever.net, and when I succeeded at it, I forgot that I had to keep testing little bits of code under the simple DOS environment to make sure my code was sane and also to advance much faster and satisfactorily. Instead, I attempted to write a full-fledged kernel at that point.

Not that it would have been useless, it's just that I bet that the problems that I faced doing things that way could have been more easily solved if I had kept writing simple snippets to implement concepts and ONLY THEN, after having a huge amount of tested and debugged isolated code, integrate it into a really usable and scalable kernel.

It has been some days ago that I actually remembered it was the best path (for me, sure for some others too) to follow. So I have been "rescuing" the sane and interesting code from all my previous kernels and turning it into snippets. I have no idea how much didactical, faster and funnier it would have been if I had kept doing things in this way.

Now I plan to keep doing this until I have enough snippets that could make together a high quality kernel. Of course I could start to build as I do other isolated tests, but I bet that the differences in the ideas at this point required for each module would make this new attempt of a kernel as bad as the others.

So, as a security measure, I recommend that you start simple until you have something. Don't expect to write a final implementation of your kernel when you don't have enough stable code and haven't tested your ideas to see how to actually implement them properly.

Also, if you don't know how to do something, accept that fact and try to find information about it, as well as examples that you personally can understand on how that specific thing is done, from the things others have done already and, if clear explanations and simple source code examples exist, use them and modify them with no doubt.

Re: Where to start OS Deving?

Posted: Mon Nov 03, 2008 7:27 am
by 01000101
I disagree with Solar's point on 'picking things up along the way'. I believe that with a decent understanding of the theory and a firm grasp on the desired programming language, OS development is all about trying things your own way, and for the most part, that means screwing up, fixing, learning, trying again... and repeat until something desirable emerges. I really doubt many (if any) people here started out wanting to conform to a bland 'beaten-to-death' implementation, I can almost guarentee that there was a striving towards a unique design (even if it is only a partial module/snippet). How exactly would one go about implementing something unimplemented or undocumented without having to just 'give it a go' and learn things along the way to improve and critisize the implementation until something works correctly.

Re: Where to start OS Deving?

Posted: Mon Nov 03, 2008 9:37 am
by Combuster
There is a difference between someone that can't program, and someone that can't program an OS. I think Solar meant that the first category should get the hell out of an subject that is far too difficult if you don't have any experience to base your work upon. People that do have programming experience have more use in experimenting around, they know what their code should do, and can fix problems should they arise.

Re: Where to start OS Deving?

Posted: Mon Nov 03, 2008 1:01 pm
by CodeCat
I don't think OSdev is a good idea if you don't know the programming language(s) well. I've programmed in C++ for several years and I'm still finding out tons of hidden features, gotchas and implementation details that I wasn't aware of before (but which would've seriously screwed up my code had I ignored them). Knowing both your language and your compiler inside out might not be an absolute requirement, it's certainly a good idea!

Re: Where to start OS Deving?

Posted: Tue Nov 04, 2008 2:11 am
by DeletedAccount
Hey ,
I would recommend the OS course present in ocw.mit.edu in the Computer and Electrical Engineering section .It is pretty good and worth a try .Even if you do not implement it , you gain a solid understanding of how to proceed by reading it . I however will not recommend an os as your first programming project , do something like an address book manager , simulations etc . You also need to have 'solid' understanding of the language in which you write the os .Read the hardware manuals and so on .These days I am trying to write my own compiler to get my os compiled since this is the safest way for me to work around the licensing issues . I will someday write my os development tutorials as well .

That being said , there is nothing aristrocratic about os development . Although it is difficult process , its is more or less similar to any other development ,except that you need to pay more attention to details.
Regards
Sandeep