First time attempting OS Dev

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Aviar
Posts: 3
Joined: Thu Sep 24, 2009 3:09 pm

First time attempting OS Dev

Post by Aviar »

First of all, this being my first post, I want to say hello to anyone who may be reading this and thank them for taking the time to view this post, even if they themselves do not actually post.

Long: Second, I recently decided (two days ago) to attempt creating an operating system kernel. Originally I thought it would be interesting to simply take the Linux kernel and modify it, but that seemed to take all the fun out of it. So instead, I wanted to try from scratch. I am not doing this to become famous, but simply because I always wanted to understand what the operating system does on an intimate level and believe that in order to be a good programmer, you must be aware of the system in its entirety (from hardware to coding theory). As with any project, I believe it is important to first come up with some sort of simple documentation that states what it is that you are trying to do. This keeps you focused on the goal. As I said before however, I am new to this (I have done C, C++, Java, Ruby, HTML, PHP, MySQL, CSS, etc. so I do have a basis with programming languages) and therefor have little experience as far as developing an operating system goes (In all honesty, I barely have experience with the Win32 API). As such, I have drafted what I deem to be a realistic and basic theoretical sketch of what my kernel should represent. However, what I believe to be realistic, and what a seasoned developer deems to be realistic are two different things, as such I wanted to ask for creative input (and cold realistic comments) over the following text; http://aviar.hobo-studios.org/drupal/no ... 15644626=1.

Short: Looking for creative and realistic input over what is most likely to be an idealistic text: http://aviar.hobo-studios.org/drupal/no ... 15644626=1.
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: First time attempting OS Dev

Post by piranha »

Alright, welcome!

I must say you are already doing loads better than most new comers: You have coding experience, and your motives are to learn. Thats doing better than me when I started. I also like that you want to do it to learn, and I assume 'for fun'.

I would suggest getting the Intel Manuals (they are free, including shipping).

Based on your design document, you've already done most of the beginning stuff though. Also, you know what languages and tools you're gonna use, thats good...

I do like your design document, and most of the questions you have left unanswered do not need to be addressed now, as they depend on the kernel first (remember, writing a good kernel is time consuming).

Good luck...

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
Aviar
Posts: 3
Joined: Thu Sep 24, 2009 3:09 pm

Re: First time attempting OS Dev

Post by Aviar »

I have procured all four of the Intel Documents 2009 Edition, and read the first volume to get the idea of what architecture I am working on. I have done some assembly before hand, and have had some basic exposure to "hacking" software from two different books I have read ("Subverting the Windows Kernel" and "The Shellcoders HandBook 2nd Edition"). Recently procured the book over Operating System Concepts (7th Edition),Secure Programming with Static Analysis, and Secure Coding 2nd Edition. I have yet to read them, but do plan to. I read most of the posts on this site, plus some other papers over memory management and coding optimization. I have started based on tutorials writing a simply operating system with GRUBs (hopefully later, I will be able to write a basic bootloader). However, most of what I have done is straight out of a tutorial or simply reading theory, thus I thought it would be best to get a real world view prespective.

P.S.: It seems to me like I am going at this in a sort of "shotgun" method, is there any particular thing I should focus on raeding first?

P.S.S; Just noticed this is in the wrong section, can any moderator move this to OS Design and Theory?
User avatar
~
Member
Member
Posts: 1228
Joined: Tue Mar 06, 2007 11:17 am
Libera.chat IRC: ArcheFire

Re: First time attempting OS Dev

Post by ~ »

Aviar wrote:I recently decided (two days ago) to attempt creating an operating system kernel. Originally I thought it would be interesting to simply take the Linux kernel and modify it, but that seemed to take all the fun out of it.

I recommend not to try to write an actual kernel right away unless you don't care about spending a lot of time which can even be years, reimplementing virtually all.

Better do the following: try to understand every basic hardware piece of the PC, then create a software counterpart for handling it. Try to make it as concise, clear and adaptable as you can so you can later integrate them in a future kernel. Do the same with software algorithms for things like the memory manager.

In this way you will not make a false illusion of progress as you "add new things" to an attempt of a kernel, but will really see how much useable code you have produced because you will see if you can actually drive the intended peripheral or not without the need of making a whole kernel that you will surely have to reimplement a second, third, etc., time as you gain experience and become able to see errors or new requirements, and you will lose enthusiasm and time whenever you have to reorder things all over again.

When you debug and order every code group, store it so you can later modify a copy instead of destroying your work with further modifications.

Then do whatever you want with your reviewed codebase if you feel you can do something big at some point, but I wouldn't recommend to do that if all you are going to do is put a small set of basic drivers in a "kernel" program.
Aviar
Posts: 3
Joined: Thu Sep 24, 2009 3:09 pm

Re: First time attempting OS Dev

Post by Aviar »

As far as time goes, I have enough time. Just started coursing as a Networking Engineer at my University, and I have five years prior experience (Started when I was 12 with Python and Hello World). I will admit I have done little in the ways of driver development, but I see starting OS development as an ideal way to learn about all the internal pieces of a computer. I know what I can come to expect from developing an operating system, and clearly understand it will take years. However, I believe I will take your advice, and make point of understanding how every piece in a computer fits together, and write some driver code (Or simply a program which makes use of a certain hardware aspect of my system). I originally was looking at FPGA in C, it seemed promising, so I might even continue that in parallel.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: First time attempting OS Dev

Post by Kevin »

~ wrote:Better do the following: try to understand every basic hardware piece of the PC, then create a software counterpart for handling it. Try to make it as concise, clear and adaptable as you can so you can later integrate them in a future kernel.
How are you going to test these drivers outside a kernel? Testing interrupt handling in a Linux/Windows userspace program sounds funny. What about drivers that depend on the driver of other components? File system implementation depends on VFS and a disk driver, say a CD-ROM, which depends on some SCSI code and an ATA driver which depends on PCI... (right, you can stop at the disk driver and access a file when you're testing unter Linux - still lots of dependencies)
When you debug and order every code group, store it so you can later modify a copy instead of destroying your work with further modifications.
The thing you're looking for is a version control system. Developing any piece of code larger than Hello World without using git/SVN/whatever should be considered a crime.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: First time attempting OS Dev

Post by gravaera »

Aviar wrote:I have procured all four of the Intel Documents 2009 Edition, and read the first volume to get the idea of what architecture I am working on.

I can only say that I am impressed. Amazing. Good work. Every possible encouragement to you.
P.S.: It seems to me like I am going at this in a sort of "shotgun" method, is there any particular thing I should focus on raeding first?
Honestly, most of the questions you'll want to ask will be covered in detail by the Intel Manuals, so I think you're going on a really steady track right now.

I hope you do well, and I'm personally rooting for you.
-gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Mark139
Member
Member
Posts: 39
Joined: Mon Jan 15, 2007 2:32 pm

Re: First time attempting OS Dev

Post by Mark139 »

I skimmed your doc. A very good start and plenty of work for you to do.

I did notice something
Avoid infinite loops like in Windows
I don't think Windows applications sit in infinite polling loops. Most of the user APIs at some point use WaitForObject(...) type calls which cause the kernel to pause the calling thread until a specific event happens - this is very efficient. It's true that at the kernel level there are some spin-locks but not many. I would recomend looking at the "inside windows" type books from MS

All the best
Mark
P.s I'm not a MS fanboy, but their kernel engineers really know what they are doing :)
p.p.s this is the book I was thinking of
http://technet.microsoft.com/en-us/sysi ... 63901.aspx
I did see it in a local shop, but it's a bit expensive in the UK
redoktober
Member
Member
Posts: 109
Joined: Thu Feb 26, 2009 12:58 am
Location: Gurgaon/New Delhi, India
Contact:

Re: First time attempting OS Dev

Post by redoktober »

i like the fact that you've drawn up a pretty good plan.
=D>
most of the time, we beginners suffer 'cause we haven't planned our project properly.

something tells me you're going to be a great guy to work with on a project.
well, good luck to you!do check out the following link sometime, and tell me what you think:
http://sites.google.com/site/thehackerlabsfoundation

i must add that the ideas posted there are now frozen, and i'm just finalizing a new project, which i'll announce in say, 2/3 days.
"Do you program in Assembly?" she asked. "NOP," he said.

"Intel Inside" is a Government Warning required by Law.
Post Reply