Hey!

I sorta, kinda want to make a REALLY simple OS that would be made in c/c++ (c++ hopefully).

I realize that it would take a lot of effort, and I would need a lot of time. But I am willing to put forth the required effort and time, so, where should I start.

I was thinking that I could use a pre-made kernel and boot loader and not do those (as I don't want to learn assembly unless there is not way around it.

Also, are there any good things that would allow me to compile the code into whatever format needed for an OS (is it *.bin?).

Thanks,
Jack

Also, I would really appreciate it if you didn't post if you were planning on saying, "try learning something else first." I know that that is true, but I'm willing, as I said before, to put forth the effort required.

Recommended Answers

All 9 Replies

So what is it that makes up an operating system? (I really don't have a clear cut answer: Too many possible ways to slice things).

By mentioning the idea of skipping the boot loader and kernel, you make it clear that you're experimenting with something less fundamental; so just pick a utility and write it. How about a linker? An editor? A (GUI or command line) shell? A music player? ... the possibilities are endless.

P.S. The first hit from Google for create Operating System

I meant that I do in fact want to make the kernel, as I now know more of what a kernel is, and I've decided that I do want to do that.


The thing is, is that I don't know quite how to load the correct files into the boot sector or any of that.

Also, I've heard that you must make the IO channels your self.

Another question: is there a way for me to test it using virtual box or the like?

OK. As will any programming project, start with a sketch of something, get it running, then extend the sketch until you've matched the specification or run out of time.

Alternatively, and easier, "steal" the kernel code from a Linux distro, and write your own, based on what you see that it does. You can also see how it gets compiled since (at least some) distros are designed to be tuned and (re)compiled for your particular system.

Don't forget the meta issues: Be sure you have source control so you can get back to a useful place; and be sure you write tests so you know it works.

I recommend not trying to use a virtual box for this. There are cheap old computers readily available. If you lived near me (you don't), I'd sell you an old Dell very cheap.

Actually, I have an old computer, how can I go about booting to it (or packaging the source for it. I've booted to a *.iso a million times). There is a program called MagicISO, is this what I'm looking for? If so, what, and how do i compile my source for putting into the *.iso?

For booting, I would recommend you take and use the GRUB bootloader. Study it and figure out how to launch a kernel with it. Then, you can start making your own kernel. Start small and go incrementally.

Making an OS is definitely one of the hardest things to do. Make sure you have a well-planned idea of what exactly you want to do, and try to reuse as much as you can (for example, you should probably try to be able to reuse drivers from another OS, like Linux). You should also comply to a standard API, like POSIX.

The OSDev website may prove to be particularly useful. When I was working on similar plans (now long since derailed by the various intrusions of harsh reality, but my life isn't necessarily yours), they were vastly helpful, and I in turn contributed to their knowledge base as I could.

You will want to tread lightly in the forums, however, as they do not suffer fools gladly - and generally assume any newcomer is a fool until they have proven their worth. I strongly advise lurking for some while and reading through the archives before posting there.

I will repeat a piece of advice given in the link Griswolf gave: C++ is not a very suitable language for kernel development, at least not without a lot of support work. Several language constructs (e.g., templates, the memory management operators) require quite a bit of runtime support from the OS, and would have to be avoided - leaving you with what is essentially C with a few add-ons. The same is true of most other popular languages, as well. While C is far from the only option, most of the other language choices - including C++ - add substantially to the initial effort and the amount of assembly programming required. If you do decided to use C++, this page will fill you in on the extra things you'll need to know.

(Of course, I am hardly one to talk about this sort of thing; one of the reasons my own OS project ran aground was my intention of developing a new systems language for it. Quite a bit of thought needs to be given about what order you do things in, in general, and writing a new language would make a significant project that would need to be nearly completed before any OS work could be contemplated.)

By the bye, what aspects of kernel design are you most interested in or curious about?

One final piece of advice: you may want to use an emulator or virtualizer for testing before trying your code out on a live machine, even if you are targeting a system dedicated for the task. The turn around time in debugging and replacing the disk image is well worth it. BOCHS works well for this, especially in the early stages of design, though it is a bit slow; VirtualBox is a good choice for later work, when timings become crucial, but requires a bit more work in setup.

I would like to know a few things:

A) How can I actually make a kernel.
B) How do I make the things that I hear about, like interrupts (what on earth... (though I think it is some sort of way of getting input from the user.))
C) How do I add these things to my project, especially in regards to making the code bootable (an ISO file, I think).
C) Is there anything that most people do wrong that is really not a good idea (like trying to use starnderd functions like "cout" or "printf")?

Thanks,
Jack

A lot of these questions can be answered at http://wiki.osdev.org, where there are extensive FAQ lists and other beginner's information that would help you understand what you are undertaking. There is even a specific page on common beginner's mistakes, which addresses the last question directly.

How do you make a kernel? Oh, how to begin... You first need to understand what a kernel is, and more importantly, what it is not. The kernel is, in effect, a program which contains the minimal operations of the system. It is responsible for managing memory; handling interrupts (a type of simple message sent by the hardware, indicating when something has occurred); starting, managing and stopping processes; and providing a mechanism for communication between processes (semaphores, messages, etc.).

That's about it.

Now, some things may be part of the kernel, but aren't necessarily, may include some common device drivers (e.g., basic disk I/O); a minimal file system (for finding the files that the kernel needs); and some ability to report error messages.

Things that are often part of or done by the operating system, but not usually inside the kernel proper, are the user file system; general-purpose I/O; loading of executable files to run as a process; loadable device drivers; higher-level IPC functions such as sockets and pipes; basic networking; and system configuration.

Things that are not part of the kernel, and usually aren't even part of the OS itself, include the graphical user interface; the user shell (the text user interface); the execution path (information about where to find executable files); and the vast majority of what the user sees as 'the system' (e.g., the web browser, the default editors and word processors, etc.).

Note that the boot loader is not part of the kernel; it is what runs before the kernel starts, and usually does nothing except load the kernel and perhaps initialize a few basic functions which the kernel needs.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.