I’m writing my own OS, intermission (updated)

Holly jumping Jesus … I just got my 15 minutes of shame/fame over the internet. I linked my “just write down what you’re thinking” blog post on dzone.com and somehow it got posted on Hacker News and from there … Shit just hit the fan. It seems that writing “I’m writing my own OS” as a blog title can be translated from “I have spare time, I want to try out new things” into “Fuck this shit, I’m going for a revolution!!!” 🙂 It’s time consuming to answer all the comments I’ve gained, so I’m writing this post as an answer to all of you.

Where do I start? First of all, thank you, every critique, every inspirational comment and every link I’ve received is of a great value – it’s more than a few hours trying to combine keywords into Google search to get some decent info. Let’s start with an about me section.

Who am I?

I’ve put some sloppy and brief info of who am I here, but I have to explain some things. I have NO degree in computer sciences at all, in fact I have a masters degree in Physical Chemistry. My bachelor and masters theses were about data analysis – so I got my degree with software programming, not with a lab experiment (well, technically it still counts as a lab experiment) 🙂

I was born in USSR. Back then when something wasn’t working, you’d fix it yourself (heck, even TVs came with a PCB layout scheme on paper, back then). I’ve learned that you can teach yourself everything, especially when we have such a great tool as Internet. I’ve taught my self how to play guitar and a piano. I’ve taught my self programming in all these languages: PHP, JavaScript, C, C++, C#, Java, Python, etc. And I’ve taught my self some basics of electronics – yes I know how transistors work, I know what resistors are for and I even know what a capacitor is. One of my side projects involves Arduino + DOGM132 dot-matrix LCD + DS3231 RTC (which I soldered myself on a SOIC2DIP board, not a biggie, but I have a problem with shaky hands :D) btw. I’m a smoker and I love coffee with sugar and milk. I know Latvian, English and Russian languages and maybe I could remember a word in Germen which I learned for 3 years in school.

I started programming when I was 8, I did it on old Swedish second-hand machine Luxor ABC 800, it had this FGBASIC (I think it was the name) language and it was all in Swedish. It was 1990 right around when the iron curtain went down. Around then we got some second-hand Macs available, so I fell in love with this GUI stuff, only around 1995 I got my first PC running DOS and QBASIC – the hacker era started for me.

All my life I’ve had this urge to dig deeper – I think it’s called scientific curiosity. And I have one problem – yes – if I don’t like something, I’ll definitely try to fix it … my way.

Last thing, before we move on to my plan on OS. I just wanted to tell you that I’m not an Apple fanboy, because I’m going to use some references to Apple here and there!

Why?

I’ve played around with this idea in my head for about 3 years now, and only now I got the courage to do some real programming, while writing it all down in my blog. I know that my posts are not well thought out and some of the facts I’ve written down might be incorrect, but it’s a draft, a note to my self, which I’m sharing with the rest of the world. And as I promised  – when I’m done with it, I’ll edit and re-post it in a tutorial manner.

I said that I’m going to use Apple as a reference, because I like where they’re heading – they are not reinventing stuff, they’re fixing broken things. Some of you say, that I have to start with the memory management, IPCs, scheduler, etc. and forget the bells and whistles of GUI. My answer – No, GUI is THE main goal, even if I don’t have a multi-threading and proper memory management.

It’s the same problem all over again – the ghosts of the past:

  • Real mode startup (1Mb RAM limit!!!)
  • Terminal (ugly black screen with grayish characters – ASCII characters!!!)
  • Floppy disk tutorials (don’t get me started)
  • VESA (OK it was a great initiative, but it’s dead by now)
  • BIOS (OK, there’s UEFI now, but i would be glad if I could just write some Assembly and burn it on EPROM/Flash as my bootcode and decide what components my motherboard will run and prepare the environment for kernel my self)
That’s just an insight of what I think needs to be forgotten for good. What I’m planing out now is – press the power button, jump to long mode, write commands to Graphics Programming Engine (GPE).

Terminal is one of the old technologies I want to get rid of, even GUI is nothing new, but where every OS fails is the black screen with gray characters – it’s for developers, and developers are still developing stuff for other developers, not for consumers. Although my OS is not intended for general public – only a fraction of it, it’s main goal still remains GUI.

Second thing in the series of the ghosts of the past (three the’s in a row, Engrish Y U SO weird 🙂 – yes x86 architecture has it’s history, but nobody is trying to avoid it (at least it seems so for now). For example the same idea of jumping directly from real mode to long mode, as I understand it, was discovered by just trying out although the manual says you can’t do that. So if you can, then do it!

Win32 API – it has it’s roots in Windows 1.0 if i’m not mistaken, and in Windows 8 you still have this history (of course you have WPF, and instead of GDI you have DirectY family or whatever the new overly abstracted framework is called). I love FLTK and I use it for my toy projects – it’s how I see myself creating an API for GUI, although I’d suggest them to use one more base class from which the Fl_Widget could be extended – Fl_Plot with only a draw(), x(), y(), w(), h() functions, for elements that don’t require event handling. CreateWindow with 11 arguments – just to create your simple drawing box, really?

Yes, over-abstraction and under-abstraction – the third thing, that’s bothering me. I’m into this “religion” called Zen-of-software-development. Keep the balance between abstraction and performance. And always keep it readable! Wasn’t the main goal of programming languages to be human readable. Well the languages themselves are, but APIs are not. What does QueryPerformanceCounter say to a seasoned developer? It says that it will query a counter of some performance, when instead it could’ve been called GetCPUCycleCount together with GetCPUCycleFrequency. And definitielly you could go into the next problem: GetCentralProcessingUnitsProcessCycleCountSinceTheStartOfTheMachine with GetCentralProcessingUnitsCycleCountPerTimeUnit 🙂 Balance!

From my professional field of work – I hate MVC and OOP PHP. Not all of it, but most of it. I don’t use WordPress (OK I use WP for my blog, but it was a test to see where WP could come in handy, and it didn’t), I don’t use Drupal, I don’t use Joomla – I have my own CMS that I’ve written 6 years ago, I’m using includes, PostgreSQL (nope, I don’t use MySQL) and I’m using objects only when necessary (for example to wrap database connections). To see why I’m doing this, you have to see performance comparison of bare installations without cache any mechanisms:

CMS Load time (seconds) Memory footprint (Mb)
WordPress 0.3 20
Joomla 0.45 12
Drupal 0.45 18
My CMS 0.3 3

Even some of my heaviest e-commerce client sites do not need any caching mechanisms to run properly (The maximum memory footprint I had with one client was 8Mb and load time around 1 second – it was a heavy product search-and-filter query that executed for about 0.8 seconds, that slowed down the load time).

So much for the things I don’t like. It might be that I’ve forgotten some things, but you might see where I’m getting at.

How?

I love Agile development practices. No, I don’t do planing – I’m going with the flow. I need to see a visual reference as soon as possible and then re-iterate all the process from the start. That’s why I wrote second part of my OS blog, just to get to booting C code ASAP. It’s the only thing that keeps me interested in any project – to see the visual results. You might say I have a short attention span, but it’s normal in the times of gazillion byte information flow.

My workflow usually consists of:

  1. Write or port a working code and run it;
  2. Be proud of what you’ve just done
  3. Analyze the code, tinker around, try to understand “why do you have to take this and that approach”;
  4. Reiterate and run it;
  5. Be proud of what you’ve done;
  6. Repeat from step 3 while adding some new functionality.

I think it’s how most of developers do stuff today. In the meantime I try to understand optimization possibilities, if and once I’ve gotten pretty familiar with the language/environment.

What?

So the master plan. This time I’ll try to lay it out in an orderly fashion:

  1. I’m targeting single hardware configuration. The product I’m aiming for is a hardware-software solution  – Apple style;
  2. I want it to be user friendly (a non-developer user that is) – GUI, UX, Accessibility and Usability are the buzzwords I’m aiming for – Apple style;
  3. It will not target the general public, just a small fraction of it;
  4. I’m not aiming for modular, micro or whatever the name is kernel, the idea is to write a base kernel software that can be re-used for my hardware-software solutions;
  5. I need a powerful multi-core CPU architecture, with speed and no power consumption restraints – the product is heavy on real-time data processing;
  6. I’m going to avoid any open-source license that forces me to unveil my proprietary code (so it’s a no-no for GPL and Linux world), BSD and MIT seems fine for now;
  7. I’m targeting only popular and modern interfaces – USB, SATA, PCIe, (Thunderbolt would be nice, but there are currently no devices available) and technologies – Intel64, GPU acceleration, etc.;
  8. I’m even planing on building my own motheboard and PCIe adapters (but that’s in the long run);
  9. As the OS it self will probably never have it’s IDE, I’m targeting the most popular desktop OS – Microsoft Windows and it’s Visual Studio Express Edition;
  10. As a base kernel code for inspiration, I’m using FreeBSD and OpenBSD kernels.

Why Windows and Visual XXX?

The problem with the Linux as I see, is the interface – it’s developed by developers for servers, system administrators and other developers – it’s a hassle to get it up and running (for an average user/seasoned developer). I know that the flamewar will start in the comments after this sentence, but this is how my Chakras feel about Linux – it’s great for my professional field of work – web development and hosting, but it’s not for an average user.

Windows on the other hand is THE most popular desktop OS and there are almost no tutorials (or they are scattered all around the web) on OS development or cross-compilation in Windows Environment. Except for Cygwin maybe, but as I showed you in my previous post you still have to learn *nix interface to setup cross-compilers. Yes there is Eclipse and there is DevC++ and there are other IDEs, and again, there are plenty of tutorials around the web on how to set them up for your development? It’s not an easy task and it kills the momentum, when a teenager just wants to type a few lines and hit “play”.

I would like to give people the opportunity, to just install Visual Studio, open up a project, write code and hit play and see how it’s own creation comes to life on my os or on his own hardware.

So, on a final note – How hard can it be, to do all this? 🙂

Update:

Actually reading more comments I come to conclusion that most of haters are Linux fanboys. Nah, just kidding.

Two things, I need to make my self clear:

  1. The OS will NOT be intended for multiple users. First of all it will be single purpose device built with standard components, running a single purpose OS – just to make it clear for those who’re criticizing my idea of directory structure. Also to mention – how many desktop PCs (and mobile devices) are used by more than one user?;
  2. Linux (and other *nixes)- it’s great – for developers like me, I use it on daily basis – I’m running 3 Debian servers (1 hosting, 1 development and 1 storage) and I’ve OpenBSD router/firewall. No problem with that. But I hate it when people bring out this argument without a context. Yes, Linux is great, it’s great for what it was created for, and, No, I will not use it’s source in my project, neither I will use any of it’s paradigms (like file system), because they are NOT for a regular user;

Join the Conversation

6 Comments

    1. Because he was writing inappropriate comments using racist terms and bringing out some conspiracy bullshit. Either he’s nuts or a troll.

        1. Oh, then I should probably remove this remark. Creepy though… :/

  1. I like your idea,courage and your enthusiasm . I’ll be waiting for tutorials and the progress of your OS.
    I wish you all the best 🙂

  2. Hi been following your project with great interest. I looked in to how linux got going a few years ago in an attempt to understand how OS’s boot on the i386 platform. Was wondering if you had come across these on your internet travels.

    http://www.codeproject.com/Articles/39027/Beginning-Operating-System-Development-Part-One
    http://www.codeproject.com/Articles/39069/Beginning-Operating-System-Development-Part-Two
    http://www.codeproject.com/Articles/43179/Beginning-Operating-System-Development-Part-Three
    http://www.codeproject.com/Articles/49813/Beginning-Operating-System-Development-Part-Four

    All the best with your project.

Leave a comment

Your email address will not be published.