Operating systems, composed of hundreds of thousands of lines of code, enable users to interact with computer hardware. They are usually written in the C, C ++ and assembler programming languages.
Step 1. First, learn programming
Knowledge of assembler is essential; It is highly recommended that you also be aware of other additional lower-level programming languages such as C.
Step 2. Decide on which device you want to boot the operating system
This can be a CD, DVD, flash drive, hard drive, or other computer.
Step 3. Decide what you want your operating system to look like
Should it be a full version of the OS with a graphical user interface (GUI), or maybe something more minimalistic? You need to know which direction to go in before starting the process.
Step 4. Check which processor platform your operating system will support
AI-32 and x86_64 are the two most common versions for personal computers, so they can be considered the best choice.
Step 5. Decide whether you prefer to do everything yourself from scratch, or if there are kernels on the basis of which you would like to build on the system
Linux from scratch is a project for those who wish, for example, to create their own Linux distribution.
Step 6. Choose whether you are going to use your own bootloader or the previously created Grand Unified Bootloader (GRUB)
Because coding your own boot program requires extensive knowledge of computer software and BIOS, it can push back the programming schedule for the actual kernel.
Step 7. Decide on the programming language you are going to use
Of course, it is quite possible to develop an operating system in a language such as Pascal or BASIC, but it is preferable to write in C or assembler. Assembler is absolutely necessary, since some important parts of the operating system require knowledge of this particular language. C ++, on the other hand, contains the keywords required to run the full OS.
To build an OS using C or C ++ code, you will, of course, use one compiler or the other. This means that you should read the manual / instructions / documentation for the C / C ++ compiler of your choice that comes bundled with the software or is available on the distributor's website. You will have to learn a lot of complicated things about the compiler, and you will also need to learn its schema and ABI to improve C ++. You are expected to understand the various execution formats (ELF, PE, COFF, regular binaries, etc.) and notice that Windows' native PE format (.exe) is copyrighted
Step 8. Select the Application Programming Interface (API)
One collection of good APIs is POSIX, as it is well documented. All Unix systems have at least partial POSIX support, so it would be trivial to add Unix programs to your operating system.
Step 9. Decide on the design
There are monolithic kernels and microkernels. Monolithic kernels perform all services in the kernel, while microkernels have a small kernel combined with a custom service implementation. In general, monolithic kernels are faster, but microkernels have better isolation and protection against possible faults.
Step 10. Consider development and teamwork
This way, you will need less time to resolve big problems, which will allow you to create a better operating system in a shorter time frame.
Step 11. Don't erase your hard drive completely
Remember, formatting your drive will permanently erase all of your data! Use GRUB or another manager to duplicate booting your computer from another OS until your version is fully functional.
Step 12. Start small
Pay attention to the little things first, such as displaying text and interrupts, before moving on to complex elements like memory management and multitasking.
Step 13. Keep a backup copy of the latest working version
This gives you some peace of mind in case something goes completely wrong with your current version of your OS or subsequent add-ons. In the event of a breakdown of your computer and the inability to boot, as you yourself understand, having a second copy for work will be an excellent opportunity, so that you can fix the existing faults.
Step 14. Test your new operating system in a virtual machine
Instead of restarting your computer every time you make changes or transfer files from your production computer to a test machine, you can use an application to run the OS in a virtual machine while your current OS is still running. VM applications include VMWare (which also has a freely available server), alternative open source, Bochs, Microsoft Virtual PC (not Linux compatible), and XVM VirtualBox.
Step 15. Release the release version
This will allow users to tell you about possible flaws in your operating system.
Step 16. The operating system should also be user-friendly, so be sure to add useful features that will become an integral part of your design
- When the development is finished, consider whether you want to make the code freely available or to establish private rights to it.
- Make sure to make security features your top priority if you want your system to be viable.
- Don't start an operating system development project for the purpose of teaching programming. If you do not know C, C ++, Pascal, or any other suitable languages and properties, including pointer types, low-level bit operations, bit switching, inline assembler, etc., then you are not ready to create OS.
- Browse portals such as OSDev and OSDever to help you improve your own operating system. Please note in particular that for most of the issues, the OSDev.org community prefers that you consult the site content yourself rather than joining the forum. If you nevertheless decide to join the ranks of the members of the forum, there must be certain prerequisites for this. You must have a thorough knowledge of C or C ++ and the x86 assembly language. You should also understand general and complex programming concepts like Linked Lists, Queues, etc. The OSDev community in its rules explicitly states that no one is going to babysit new programmers. If you are trying to develop an OS, it goes without saying that you are a "god" in the field of programming. You are also required to read the processor manual for the architecture of your choice; for example x86 (Intel), ARM, MIPS, PPC, etc. Such a reference to processor structure can be easily found by searching Google ("Intel Manuals", "ARM manuals", etc.). Don't sign up on the OSDev.org forum to ask obvious questions. It will just lead to answers like "Read the f *** ing Manual". To get started, you should try reading Wikipedia, tutorials for the various tools you intend to use.
- Check for potential blind spots and other bugs. Shortcomings, dead ends, and other issues can affect the design of your operating system.
- If you want an easier way, imagine Linux distributions such as Fedora Revisor, Custom Nimble X, Puppy Remaster, PCLinuxOS mklivecd, or SUSE Studio and SUSE KIWI. However, the OS you create is owned by the company that first introduced the service (although you have the rights to freely redistribute, modify and run it as you like under the GPL).
- A good solution is to create a completely new partition for the operating system under development.
- Careless rewriting of the OS to the hard drive can damage it completely. be careful
- You won't have a complete system in two weeks. Start with a bootable operating system and then move on to more interesting material.
- If you do something reckless, like write messy bytes in random I / O ports, then destroy your OS and can (in theory) burn your hardware.
- Don't expect it to be easy to build a quality operating system. There are many complex interdependencies. For example, for an OS to be able to handle multiple processors, your memory manager must have "locking" mechanisms to prevent unnecessary processors from accessing the same resource at the same time. The "blocks" used assume a scheduler to make sure that only one processor is accessing a critical resource at any given time, and all others are idle. However, the scheduler depends on the presence of the memory manager. This is an example of a deadlock dependency. There is no standard way to solve these kinds of problems; each operating system creator is expected to be skilled enough to come up with their own solution.