OS from Scratch

Although the title is part of my question, the second part will not be so simple. The first part: let's say I want to create my own operating system. How can I do it? I understand that I need to create a bootloader. But where am I going from there? I would have to send it to another program, but for this, this program should already be there, and I must know exactly where it is in memory. Any tips / tutorials?

Second question. I'm currently studying memory management, and I think I have a theory about the best implementation of the allocation algorithm, but I have no way to really test it, except in theory. As soon as I can create an OS (so this is for future reference), how do I actually interact with main memory and move processes?

PS: Also, should I write my own file system?

Edit: After reading the current comments, I want to review what I said. When I said, β€œThe second part will not be so simple,” it seems like a bad choice in words. I know that both will be very difficult endeavors, but that does not matter to me. I just like to learn new things. And I didn’t want anyone to write a textbook for me, just to point me in the right direction.

+4
source share
9 answers

Phew Now this is a question! I don’t think that any answer that you get here will cover such a huge territory (unless someone sits down to write and review within an hour or two).

I suggest you familiarize yourself with operating systems first - try Tanenbaum and OSDev.org for quick links.

You can use GRUB as your bootloader - this should simplify the situation.

+5
source

I do not agree that the name is a simple part. You may consider exploring minix

+3
source

You might want to consider modeling (in whole or in part) the operating system, as opposed to the actual spelling. Depending on the model, she can get more from her with less effort.

I know in my approach, we wrote disk scanning algorithms in Java; it was just Java with several classes and interfaces. He didn’t really look at the disk, but he did decent enough work so that we could measure, test and tune the algorithm to see how it changed.

So, I suggest something simpler: if you are only after memory algorithms, perhaps you can write a small test, customizable application that will allow you to go directly to what you want to do and not worry about β€œyou have to write differently.

Alternatively, playing with an existing (UNIX / Linux) OS may be less effort than writing something new from scratch.

+3
source

This is not an easy job, but in which you learn a lot. I recommend going to http://wiki.osdev.org/Main_Page , as there are a lot of tutorials on this site and you will probably start.

+1
source

Most of the components that you described (memory manager, FS) can be implemented, tested and used without writing an OS for them.

Also, the bootloader is not really the first thing you should start with. You see, there must be something that is uploaded by him. And this is something (that needs to be developed and tested) would be much more complicated than the bootloader.

It seems that you underestimate the amount of work (and knowledge!) Necessary for this. The best you can do is find a friend who wants to explain this to you and talk to him for an hour.

+1
source

The theoretical book on operating systems Operating system concepts will really help you. For any OS, you need a scheduler that will handle task switching, context switching, traps, etc.

0
source

Another good reference book that you might want to consider is:

Good luck with this endeavor. I mean, good luck.

0
source

Learn Linux and the best bits of Minix, and if you go with a ready-made bootloader, as some of them suggested, I would go with LILO on GRUB (these are, of course, only personal prefs).

0
source

Pritam Zope and theMike97 have awesome Youtube tutorials on how to write an OS from scratch. TheMike97 has a series of articles about writing your own bootloader, and Pritam zope teaches you how to write your own kernel in asm and c. Here is my current bootloader if you want to start somewhere with. it just prints hello world.

org 0x7c00 mov si, message ;The message location *you can change this* call print ;CALL tells the pc to jump back here when done jmp $ print: mov ah, 0Eh ;Set function .run: lodsb ;Get the char ; cmp al, 0x00 ;I would use this but ya know u dont so use: cmp al, 0 ;0 has a HEX code of 0x48 so its not 0x00 je .done ;Jump to done if ending code is found int 10h ;Else print jmp .run ; and jump back to .run .done: ret ;Return message db 'Hello, world', 0 ;IF you use 0x00 ;message db 'Hello, world', 0x00 times 510-($-$$) db 0 dw 0xaa55 ~ 

save this code in a file called main.asm compile it with nasm -fbin main.asm -o main.bin run it with qemu-system-x86_64 main.bin

0
source

All Articles