Overclock.net › Forums › Software, Programming and Coding › Operating Systems › How to start an OS from scratch
New Posts  All Forums:Forum Nav:

How to start an OS from scratch - Page 2

post #11 of 25
Quote:
Originally Posted by blue-cat View Post

As I said this was a hypothetical question about how it was done not a one man mission to create the OS of the future. That said I think that if I ever were to decide to pointlessly dedicate my life to such an unobtainable goal (or if I am just interested like I am now) then your advice is actually useful. Thanks! smile.gif
First of all, I recommend you familiarise yourself with C (some kernels are written in C++, but back when I was experimenting with writing my own OS, all of the tutorials were in C and assembly. This was 10 years ago though, so things may have changed).

Also learn about how existing kernels work. Spend about a week researching how paging works in Linux and Windows. Learn how drivers are loaded, the difference between monolithic kernels and micro kernels. And think about how you want all that to tie into your own project (don't be afraid to start off with very little ambition; eg a monolithic 32bit kernel with no binary support and no paging. It's better to build something useless but learn the theory than attempt something magnificent but fail at the first hurdle and thus learn nothing). You may even find that you'll want to build more than one OS (one to learn the theory, and one with cleaner code and a longer term (read: more ambitious) plan.

Most of the information you'll need to get started can be found here: http://wiki.osdev.org/Main_Page . Then as you progress, you'll start stumbling across other resources (partly through better understanding what to Google, and partly through stumbling across other resources while searching of unrelated material). For now, I wouldn't bother with Wikipedia as the articles on there will be more tailored from a user perspective than a developers. As in, you'll be more interested in understanding how to implement specifications than just seeing spec sheets (that's not to say you can't refer back to Wikipedia to help translate some of the theory, but I don't think it's going to help you lay down any code)

However even with the excellent documentation online and all the theory you've now amassed, you're not at a stage where you can dive in a code your own kernel. So grab an open source kernel and work from there. It was quite a few years ago now, but I think I used bkerndev as my template: http://www.osdever.net/bkerndev/Docs/title.htm however there are other kernels online (avoid the likes of Linux, Haiku and even Minix for now - they're going to be way too complicated for you at this stage). The nice thing about projects like bkerndev is they'll walk you through building a kernel so you'll find those tutorials stacked full of great theory to compliment the other resources.

Lastly, be prepared to loose years of your life before you have anything worth showing to your friends. This is a labor of love, it wont be the next Linux. But I think you already know this smile.gif

Enjoy mate
Quote:
Originally Posted by jrl1357 View Post

(Shakes head) write your own OS? Yeah, sure. No, the closest you can come without millions of dollars and/or years of work would be to do a Linux From Scratch install. But really, anyone who 'knows a little C++' but thinks they can write an OS knows nothing. The codebase of most Linux distrobutions was built over years, and by thousands of people writing software from the kernel to the desktop.

If you want to learn more about how an OS works, I suggest you get used to Linux via Ubuntu and then do an Arch Linux install. If you still want to know more after that, you can build your own distro with Linux From Scratch.

Stop being a Daisy Downer tongue.gif
Edited by Plan9 - 4/3/13 at 1:42am
post #12 of 25
Quote:
Originally Posted by jrl1357 View Post

(Shakes head) write your own OS? Yeah, sure. No, the closest you can come without millions of dollars and/or years of work would be to do a Linux From Scratch install. But really, anyone who 'knows a little C++' but thinks they can write an OS knows nothing. The codebase of most Linux distrobutions was built over years, and by thousands of people writing software from the kernel to the desktop.

If you want to learn more about how an OS works, I suggest you get used to Linux via Ubuntu and then do an Arch Linux install. If you still want to know more after that, you can build your own distro with Linux From Scratch.

While true that there are many thousands of hours invested in the Linux OS, that does not mean it's impossible to write your own little operating system.

I recommend reading Andrew Tanenbaum's book on how to design a basic operating system: http://www.amazon.com/Operating-Systems-Design-Implementation-3rd/dp/0131429388/ref=la_B000AQ1UBW_1_3?ie=UTF8&qid=1365087349&sr=1-3

His book is based on his design of the Minix OS, which was likely the inspirational source for Linus Thorvald when he started on Linux.
post #13 of 25
Quote:
Originally Posted by jvjessen View Post

His book is based on his design of the Minix OS, which was likely the inspirational source for Linus Thorvald when he started on Linux.
It wasn't. Minix and Linux are very architecturally different - in fact there use to be frequent arguments between them in regards to kernel design (aka the famed monolithic vs micro kernel flamewars)

Linux was inspired by Unix. Minix only served as a platfrom to develop Linux on before the kernel (and GNU's userland) had matured.
post #14 of 25
Quote:
Originally Posted by Plan9 View Post

It wasn't. Minix and Linux are very architecturally different - in fact there use to be frequent arguments between them in regards to kernel design (aka the famed monolithic vs micro kernel flamewars)

Linux was inspired by Unix. Minix only served as a platfrom to develop Linux on before the kernel (and GNU's userland) had matured.

Agree, he took a different approach on the kernel design (higher performance at the expense of possible lower reliability), but I do believe he was generally inspired by the work already done by Andrew Tanenbaum.

They are both very much inspired by Unix, which I guess they make quite clear with their X'es in the names smile.gif
post #15 of 25
Quote:
Originally Posted by jvjessen View Post

Agree, he took a different approach on the kernel design (higher performance at the expense of possible lower reliability), but I do believe he was generally inspired by the work already done by Andrew Tanenbaum.

They are both very much inspired by Unix, which I guess they make quite clear with their X'es in the names smile.gif
"inspired" is such a generalised term that on some level you're bound to be right. My issue was more with your former statement: "His book is based on his design[2] of the Minix OS, which was likely[1] the inspirational source for Linus Thorvald when he started on Linux." which is more assertive[1] as well as stating that Linux's design was based upon Minix[2] which is definitely not true in the slightest as their architectures are vastly different.

While we're on this topic, I also don't think it's a good idea for the OP to jump in with a book about Minix just yet. As I'd already covered in my lengthy post above, projects like bkerndev will give a much more basic overview about building your own kernel. Then once he has worked his way through that he can progress onto Minix if he so wishes. Given his lack of education on this subject (and I don't mean that in a condescending way because there's PhDs dedicated to OS development) and basic skills in C, he's far better off taking baby steps first.
Edited by Plan9 - 4/4/13 at 10:31am
post #16 of 25
Quote:
Originally Posted by Plan9 View Post

"inspired" is such a generalised term that on some level you're bound to be right. My issue was more with your former statement: "His book is based on his design[2] of the Minix OS, which was likely[1] the inspirational source for Linus Thorvald when he started on Linux." which is more assertive[1] as well as stating that Linux's design was based upon Minix[2] which is definitely not true in the slightest as their architectures are vastly different.

While we're on this topic, I also don't think it's a good idea for the OP to jump in with a book about Minix just yet. As I'd already covered in my lengthy post above, projects like bkerndev will give a much more basic overview about building your own kernel. Then once he has worked his way through that he can progress onto Minix if he so wishes. Given his lack of education on this subject (and I don't mean that in a condescending way because there's PhDs dedicated to OS development) and basic skills in C, he's far better off taking baby steps first.

I think we generally agree here smile.gif .. I have continuously said "likely", and I know Linus wouldn't admit it. But taking facts into account that he was active in the Minix community at the time and called out for people interested in doing a free (Minix is was not a free OS, although was very cheap compared to Unix at the time) alternative with a few changes, pretty much says he was inspired. And that Andrew supplied sources with his OS distribution makes it even more likely .. anyway, no one besides the involved parties can know what exactly happened and we are moving outside the scope of this topic smile.gif

Personally I find Andrew Tanenbaum's books very approachable and digestible, you don't have to be an expert to get a good understanding of what is required to implement a basic operating system. I find many other sources tend to stray away from the core subject to promote one architecture over another. The core is really the understanding of what does an OS do and how would you go about building one. In answering that I find the Minix examples very well structured without getting into the much more complicated topics. As far as I remember he also got some great books on hardware architecture and networking basics.
post #17 of 25
Quote:
Originally Posted by jvjessen View Post

I think we generally agree here smile.gif .. I have continuously said "likely", and I know Linus wouldn't admit it. But taking facts into account that he was active in the Minix community at the time and called out for people interested in doing a free (Minix is was not a free OS, although was very cheap compared to Unix at the time) alternative with a few changes, pretty much says he was inspired. And that Andrew supplied sources with his OS distribution makes it even more likely .. anyway, no one besides the involved parties can know what exactly happened and we are moving outside the scope of this topic smile.gif
You're making a dangerous number of assumptions to make a tenuous point that isn't even documented. What's more, distributing sources with Unix was pretty normal as well - so even the odd factually accurate remark you've made is somewhat moot.

I mean, I'm not going to totally discount the possibility that there might have been some inspiration there, but I do think you're overstating things given what we do know and how open Linus has always been about his views and the development of Linux.
Quote:
Originally Posted by jvjessen View Post

Personally I find Andrew Tanenbaum's books very approachable and digestible, you don't have to be an expert to get a good understanding of what is required to implement a basic operating system. I find many other sources tend to stray away from the core subject to promote one architecture over another. The core is really the understanding of what does an OS do and how would you go about building one. In answering that I find the Minix examples very well structured without getting into the much more complicated topics. As far as I remember he also got some great books on hardware architecture and networking basics.
Well, like I said in my original post, I have been in the same position as the OP and the advice I'm giving is what I did when I was writing my own kernel. And with the greatest of respect to your suggestions, it's one thing understanding the principles, but a completely other thing having to lay down your own code in a language you're still getting to grips with smile.gif
post #18 of 25
Not just assumptions, a good introduction is this video of a lecture:

"Uploaded By Andrew Tanenbaum: MINIX started in 1987 and led to several offshoots, the best known being Linux. MINIX 3 is the third major version of MINIX and is now focused on very high-reliability and security."



His book is build around the actual source code, so it is really very focused on both the theory and the actual implementation.
post #19 of 25
Quote:
Originally Posted by jvjessen View Post

Not just assumptions, a good introduction is this video of a lecture:

"Uploaded By Andrew Tanenbaum: MINIX started in 1987 and led to several offshoots, the best known being Linux. MINIX 3 is the third major version of MINIX and is now focused on very high-reliability and security."
Given Minix 1 and 2 didn't have a copyleft license, it would be grossly inaccurate to call Linux an "offshoot" (which implies fork). At least your comment about "inspiration" is technically sound.
Quote:
Originally Posted by jvjessen View Post

His book is build around the actual source code, so it is really very focused on both the theory and the actual implementation.
Have you actually written your own kernel or are you just in love with Minix? Have you actually read anything that I've posted? I'm only going to say this one last time: I don't have a problem with the OP going over that book, but the Minix kernel is a large and complicated beast. The OP doesn't have the experience nor skills to tackle anything that complicated yet. Where as the projects I've exampled are just about learning to code the absolute basics. It's about baby steps; learn the foundations then build up from there rather than jumping in with one of the most complicated kernel designs and then trying to keep your head above water.
post #20 of 25
Quote:
Originally Posted by Plan9 View Post

Given Minix 1 and 2 didn't have a copyleft license, it would be grossly inaccurate to call Linux an "offshoot" (which implies fork). At least your comment about "inspiration" is technically sound.

I quoted the description added by Tanenbaum, the interpretation of "offshoot" you will have to take with him.
Quote:
Have you actually written your own kernel

Not relevant, but yes, I have done a number of experimental kernels, e.g. to simulate concurrent executions with shared resources and semaphores using single core processors.
Quote:
or are you just in love with Minix?

Not sure where that is comming from. I do not consider Minix a generally usable operating system, but it does demonstrate a specific design approach and because of it's simplicity it makes for a good study into how to implement one.
Quote:
Have you actually read anything that I've posted?

I don't recall arguing against your suggested material, I'm sure it's all good stuff, but often well written books can offer a more structured approach.
Quote:
I'm only going to say this one last time: I don't have a problem with the OP going over that book, but the Minix kernel is a large and complicated beast.

Well as I see it, you took objection to my statement that the creation of Linux was inspired by Minix. I added that statement to give an idea of what Minix is, and to put it into perspective, to a person who haven't already studied operating systems. Purely by name it could easily be confused as being one of the many Linux flavor.

Just to add, I had a quick look, this is what Wikipedia says on the subject:

"The design principles Tanenbaum applied to MINIX greatly influenced the design decisions Linus Torvalds applied in the creation of the Linux kernel.... "

What makes Minix a good example to study is in fact it's clean simplicity. The core of it is just a few 1000 lines of C code and it was primarily designed to teach the inner workings of an operating system. I wouldn't exactly call it complicated or bloated.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Operating Systems
Overclock.net › Forums › Software, Programming and Coding › Operating Systems › How to start an OS from scratch