How to Create an Operating System (with Pictures)

Table of contents:

How to Create an Operating System (with Pictures)
How to Create an Operating System (with Pictures)
Anonim

Operating systems allow users to interact with computer hardware components, and are made up of hundreds of thousands of lines of code. They are usually written with the following programming languages: C, C ++ and Assembly.

Steps

Make a Computer Operating System Step 1
Make a Computer Operating System Step 1

Step 1. Learn to code before you start

Assembly language is essential, and it is strongly recommended that you know another low-level language such as C.

Make a Computer Operating System Step 2
Make a Computer Operating System Step 2

Step 2. Decide on which media you want to load your operating system

It can be a floppy, a CD, a DVD, a flash memory, a hard drive or another PC.

Make a Computer Operating System Step 3
Make a Computer Operating System Step 3

Step 3. Decide what your operating system should do

You will need to know your goal from the start, whether it is a full GUI (graphical user interface) operating system or a more basic system.

Make a Computer Operating System Step 4
Make a Computer Operating System Step 4

Step 4. Choose the platforms that will be able to run your operating system

If in doubt, choose X86 (32bit) platforms, because most computers use X86 processors.

Make a Computer Operating System Step 5
Make a Computer Operating System Step 5

Step 5. Decide if you want to build your system from scratch, or rely on an existing kernel. Linux from Scratch for example it is a project for those who want to build their own version of Linux. Read the tips to find the link to the project.

Make a Computer Operating System Step 6
Make a Computer Operating System Step 6

Step 6. Decide if you will use your own Bootloader or an existing one such as Grand Unified Bootloader (GRUB)

While writing your bootloader yourself will give you a lot of information about the BIOS and hardware, it may slow you down in kernel programming. Read the "Tips" section.

Make a Computer Operating System Step 7
Make a Computer Operating System Step 7

Step 7. Decide what programming language to use

Although it is possible to write an operating system in BASIC or Pascal, it is recommended to use C or Assembly. Assembly is required, because some vital parts of the operating system require it. C ++, on the other hand, contains keywords that need a full operating system to run.

To compile an operating system from C or C ++ code, you will need to use a compiler. You should therefore read your compiler's user manual. Look for it in the program box or on the manufacturer's website. You will need to know many intricate aspects of your compiler, and to develop C ++, you will need to know how your compiler and its ABI work. You will need to understand the different formats of executables (ELF, PE, COFF, plain binary, etc.) and know that the Windows proprietary format, PE (.exe), is copyrighted

Make a Computer Operating System Step 8
Make a Computer Operating System Step 8

Step 8. Decide which API (application programming interface or application programming interface) to use

A good API is POSIX, which is well documented. All Unix systems at least partially support POSIX, so it will be very easy to import Unix programs to your operating system.

Make a Computer Operating System Step 9
Make a Computer Operating System Step 9

Step 9. Decide on your design

There are monolithic kernels and micro kernels. Monolithic kernels implement all services in the kernel, while micros have a small one in combination with user daemons (background processes) that implement the services. Generally, monolithic kernels are faster, but microkernels are more reliable and errors are better isolated.

Make a Computer Operating System Step 10
Make a Computer Operating System Step 10

Step 10. Consider developing the operating system by working as a team

This way the process will be faster and you will reduce errors.

Make a Computer Operating System Step 11
Make a Computer Operating System Step 11

Step 11. Don't wipe your hard drive entirely

Remember, formatting your drive will delete all data and is an irreversible process! Use GRUB or another boot manager to boot your dual OS computer, at least until yours is fully functional.

Make a Computer Operating System Step 12
Make a Computer Operating System Step 12

Step 12. Start from the bottom

Start small, like showing some text and breaks before dealing with things like memory management and multitasking.

Make a Computer Operating System Step 13
Make a Computer Operating System Step 13

Step 13. Make a backup of the latest working source code

If you make some terrible mistake or if the computer you were developing the system on breaks down, it's a great idea to always have a backup copy.

Make a Computer Operating System Step 14
Make a Computer Operating System Step 14

Step 14. Test your new operating system with a virtual machine

Instead of continually rebooting your computer every time you want to make a change or transfer files from your development computer to your test computer, you can use a virtual machine to run your operating system directly on your computer. Some examples of virtual machines: VMWare (which offers a free server), the open-source alternative Bochs, Microsoft Virtual PC (not compatible with Linux), and xVM VirtualBox. Read the "Tips" for more information.

Make a Computer Operating System Step 15
Make a Computer Operating System Step 15

Step 15. Release a "trial version"

This will allow users to tell you about problems with your operating system.

Make a Computer Operating System Step 16
Make a Computer Operating System Step 16

Step 16. Remember, an operating system should be easy for any user to use

Advice

  • Do not start an operating system to learn programming. If you don't already know C, C ++, Pascal, or another programming language perfectly, including pointer manipulation, low-level bit manipulation, bit shifting, assembly, etc., you are not ready to build an operating system.
  • If you want to make things easier, consider using Linux templates like Fedora Revisor, Custom Nimble X, Puppy Remaster, PCLinuxOS mklivecd, or SUSE Studio and SUSE KIWI. The operating system, however, will be owned by the company that offered you the service (even if you have the right to distribute, modify and run it under the GPL license).
  • After you've finished development, decide whether your system will be open source or your own.
  • Use websites like OSDev and OSDever to help you develop. Note that for the most part, the OSDev.org community will prefer that you just use their wiki, and not ask questions on the forums. If you decide to join the forum, there are prerequisites: You will need to have a thorough knowledge of C or C ++, and x86 Assembly. You will also need to understand the general and complex concepts of programming, such as Linked Lists, Codes, etc. The OSDev community, in its rulebook, explicitly states that it will not babysit inexperienced programmers. If you are looking to build your own operating system, you should be a true programming expert. You will also need to read the processor manual, to learn about the processor architecture that will house your system, for example x86 (Intel), ARM, MIPS, PPC, etc. You can find them easily on Google. Don't sign up to the OSDev.org forums to ask trivial questions. You will get rude answers and no one will help you.
  • It may be a good idea to create a new partition for to develop the operating system.
  • Try to identify problems and errors.
  • For more information, visit these sources.

    • Manuals: Linux From Scratch
    • Bootloader: GRUB
    • Virtual machines: Bochs, VM Ware, XM Virtual Box.
    • Processor Manuals: Intel manuals
    • Sites on the development of operating systems: OSDev, OSDever

    Warnings

    • You won't be able to build a complete, working system in two weeks. Try to create a system that starts up first, then moves on to the more advanced aspects.
    • If you do something stupid, like writing random bytes to random I / O ports, you will crash your operating system, and you could (theoretically) destroy your hardware. For a demonstration, run 'cat / dev / port' on Linux as root. Your computer will crash.
    • Be sure to implement security measures if you want to use your own operating system.
    • Running a poorly written operating system can completely corrupt your hard drive. Be careful.
    • Don't think programming an operating system is easy. There are often intricate interdependencies. For example, to create an operating system that can handle multiple processors, your memory management program will need to be able to block the resources used by one processor so that two processors cannot access it at the same time. To create these blocks you will need a scheduler that manages the activity of the processors. The scheduler in turn depends on the presence of a memory management program. This is a case of addiction. There is no standard procedure for solving problems like this; every operating system programmer must be capable enough to find a personal solution to these kinds of problems.

Recommended: