LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Can i Create My Own OS (https://www.linuxquestions.org/questions/linux-desktop-74/can-i-create-my-own-os-4175735869/)

bekoikc 04-10-2024 12:09 PM

Can i Create My Own OS
 
Hello Guys, Today, a thought crossed my mind: “What if I had my own operating system?” I began my research and discovered that operating systems are typically written in the C programming language. However, I’m well-versed in Python. So, the question arises: Can I create my own operating system using Python?

jayjwa 04-10-2024 12:40 PM

No. What would run the Python code? You'd have to write some sort of special purpose Python interpreter and compile it to executable, then get the UEFI firmware to hand control off to it. How would you do low-level device IO and graphics with Python? Lots of teams have tried to write their own OSs, many have failed. It's a massive task.

business_kid 04-10-2024 01:45 PM

Quote:

Originally Posted by bekoikc (Post 6495188)
Hello Guys, Today, a thought crossed my mind: “What if I had my own operating system?” I began my research and discovered that operating systems are typically written in the C programming language. However, I’m well-versed in Python. So, the question arises: Can I create my own operating system using Python?

I think it's safe to say that if you have to ask the question, you don't know ¼ enough to design a PC operating system. It's not just banging a few programs together, that's only the beginning. There's a huge deal of work in designing the glue that makes those programs work together. Even comparatively simple stuff like setting all the LC_* settings and knowing what programs/scripts use each one is something I'll bet you'd have to research. I certainly would. There's 1000s of those sort of tasks requiring deep knowledge.

At the other end of the scale, much simpler systems set a much lower bar. I designed something around a microcontroller in 2001 and the program that made it function was the "OS."

rclark 04-10-2024 02:03 PM

Quote:

Can I create my own OS?
You bet. But.... As said above it is a lot of work to finally get 'self hosting' and certainly not with Python. But 'simplest' way to start is write a RTOS that runs on the platform, and then build from there... One of the platforms I've played with is Ultibo ( https://ultibo.org/ ) ... A lot of work when into just project which isn't self hosting, but is the only 'application' (think OS) running on the SBC (or a micro-controller). Just Ultibo, you, and the hardware. Fun! Should add and this is with a proprietary 'blob' that initializes the hardware (think interrupt tables, memory initialization, SSD access with basic disk format reading, say FAT) and then loads your application into memory to start running. Normally you'd have to write that 'blob' yourself to get started with assembly and/or say C -- cross compiling.

bekoikc 04-10-2024 02:11 PM

Quote:

Originally Posted by business_kid (Post 6495202)
I think it's safe to say that if you have to ask the question, you don't know ¼ enough to design a PC operating system. It's not just banging a few programs together, that's only the beginning. There's a huge deal of work in designing the glue that makes those programs work together. Even comparatively simple stuff like setting all the LC_* settings and knowing what programs/scripts use each one is something I'll bet you'd have to research. I certainly would. There's 1000s of those sort of tasks requiring deep knowledge.

At the other end of the scale, much simpler systems set a much lower bar. I designed something around a microcontroller in 2001 and the program that made it function was the "OS."

yes bro your'e right but like i said it's just a idea. Thanks man!

bekoikc 04-10-2024 02:13 PM

Quote:

Originally Posted by business_kid (Post 6495202)
I think it's safe to say that if you have to ask the question, you don't know ¼ enough to design a PC operating system. It's not just banging a few programs together, that's only the beginning. There's a huge deal of work in designing the glue that makes those programs work together. Even comparatively simple stuff like setting all the LC_* settings and knowing what programs/scripts use each one is something I'll bet you'd have to research. I certainly would. There's 1000s of those sort of tasks requiring deep knowledge.

At the other end of the scale, much simpler systems set a much lower bar. I designed something around a microcontroller in 2001 and the program that made it function was the "OS."

yes man your'e right thanks!

bekoikc 04-10-2024 02:13 PM

Quote:

Originally Posted by jayjwa (Post 6495194)
No. What would run the Python code? You'd have to write some sort of special purpose Python interpreter and compile it to executable, then get the UEFI firmware to hand control off to it. How would you do low-level device IO and graphics with Python? Lots of teams have tried to write their own OSs, many have failed. It's a massive task.

yes man right thanks

pan64 04-11-2024 03:59 AM

Yes. You have got a lot of no, here is a yes. Although you cannot write a full OS in python (as it was explained), but you can implement an emulator in python, which will mimic an OS.
But would be better to start with a simple thing, not an OS, let's say with a terminal. Later you can improve it to do more and more (and will look like an OS). As it was mentioned it is a massive task.

Turbocapitalist 04-11-2024 05:10 AM

You might also look at a "unikernel" for your project. If not directly applicable, it might provide some ideas.

EdGr 04-11-2024 10:43 AM

One person can realistically write about 0.1% of the code in a modern OS.

One needs to choose those areas carefully, and of course, leverage the work of a thousand helpers.
Ed

wpeckham 04-11-2024 11:35 AM

You CAN write your own OS, but not in an interpreted language. You would need a Python compiler that outputs static native runtime executables without dependencies. And even then there may issues.

Before C most OS code was in assembler, and that is still an option. (See Kolibri/KolibriOS as an example.) Some current projects are leaning on RUST. One I know went back to Pascal because of the structure, protections, and assembler collusion features supporting multi-level coding.

You might see if you can find a copy of the dragon book (Compiler Construction) and create your own compiler, but that project is likely to take longer than just learning to RUST.

Either way, there is a learning curve and a lot of time involved. Not a quick decision...

___ 04-12-2024 02:58 AM

This seems to be a FAQ that web-searching would find lots of ideas.
To me, LFS, gentoo & mll seem like using bash to 'assemble' a linux(= just the kernel) 'distro'!
Might depend on what parts/functions of an OS interest you the most.

wpeckham 04-12-2024 09:38 AM

Quote:

Originally Posted by ___ (Post 6495435)
This seems to be a FAQ that web-searching would find lots of ideas.
To me, LFS, gentoo & mll seem like using bash to 'assemble' a linux(= just the kernel) 'distro'!
Might depend on what parts/functions of an OS interest you the most.

Starting from one of those and making custom changes would be making your own DISTRIBUTION, not making your own OS.

On the other hand, it would be a lot less work!

jr_bob_dobbs 04-12-2024 10:23 AM

http://wiki.osdev.org/

business_kid 04-14-2024 04:03 AM

If you wanted to fix screensavers turning off the monitor, ask yourself what you would check? I don't know to what extent you're following other threads, but there's interesting things going on thaqt give an insight to the issues you can face building a distro.
https://www.linuxquestions.org/quest...on-4175735987/
https://www.linuxquestions.org/quest...nt-4175735916/

Various people have had various issues around screensavers,suspend/hibernate/power-off behaviour and as you see, elogind & polkit have been fingered. Although in my case, something else seems involved also. How logical is that?

My point is: There's a very real chance of you ending up with all your programs sitting up and running, but your efforts being nowhere near release status because subtle config imperfections are making life hell. The standard out there now is high. Most distros have decades of experience, miles of scripts and special purpose utilities. Or else, they have someone behind them who has assimilated such experience.


All times are GMT -5. The time now is 01:28 PM.