'Is it possible to create an operating system using Python? [closed]

Is it possible to make a minimalistic operating system using Python?
I really don't want to get into low-level code like assembly, so I want to use a simple
language like Perl, Python. But how?



Solution 1:[1]

Unfortunately Python is classified as a very high level programming language. It cannot be used, for example, to directly access hardware and perform low-level data structure manipulation. It is completely dependent on something to abstract the hardware from it, and that is the Kernel. It is, however, technically possible to create an operating system centered on Python, that is; have only the very low level stuff in written in C and assembly and have most of the rest of the operating system written in Python.

This article discusses with more detail what languages are suitable for writing operating system kernels.

Solution 2:[2]

You can certainly run Python without an OS, as shown by the The Intel BIOS Implementation Test Suite (BITS) Project. The scripting guide explains:

"... includes Python APIs to access various low-level functionality of the hardware platform, including ACPI, CPU and chipset registers, PCI, and PCI Express. You can write scripts to explore and test platform functionality, using the full power of Python in 32-bit ring 0, without an OS in the way.. "

Now, BITS is a BIOS testing platform specific to Intel hardware, and not meant to run a custom Python based OS, but that doesn't mean you couldn't try it...

Solution 3:[3]

I have ported Python interpreter to run in my operating system as a userspace program, it was the first program - and so far the only - that I ported; from this experience, I'd say it would certainly possible to write lots of the operating system functionality in Python; you can certainly even embed Python in the kernel with rather minimal feature support.

However you need to write assembly and C for the interrupts, low level memory management and so. In my case, I built a specially modified Python 2.5.2 against the Newlib C library; in minimal case you just need to provide heap memory management for the Newlib library, and you can have Python running on top of it.

As such, Python interpreter does not contain its own heap implementation, and it does depend on the C library, so you cannot run it on bare metal right away, but much more of the operating system kernel as is conventionally written, could also could be written in Python.

The special case of course are the microkernels, where much of the functionality is in userspace as services; these can be more naturally implemented in any preferred programming language, Python included.

Solution 4:[4]

I suggest you find a good textbook on operating system design, and study that. I'm pretty sure you won't find such a book with Python source code; C is more likely. (You might find an older textbook that uses Pascal instead of C, but it's really not that different.)

Once you have studied operating systems design enough to actually be able to write an operating system, you will know enough to have your own opinions on what languages would be suitable.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dougvj
Solution 2 gens
Solution 3 Antti Haapala -- Слава Україні
Solution 4 steveha