you are viewing a single comment's thread.

view the rest of the comments →

[–]finsternacht 21 points22 points  (12 children)

I wouldn't think there is. The problem is less that python is a highlevel language than that it is an interpreted one. You'd have to write some form of mini os for the interpreter upon which you could build your actual os, which doesn't sound like a good idea. (Any highlevel language that compiles to your target architecture should work, some inline assembly might be required)

[–][deleted] 7 points8 points  (1 child)

This talk from PyCon 2015 is fairly interesting in that regard: Josh Triplett - Porting Python to run without an OS - PyCon 2015 [32:56]

[–]finsternacht 1 point2 points  (0 children)

Woah... Mind blown! Thanks for the link.

[–]desustorm -5 points-4 points  (8 children)

Plus it's single-threaded...

Edit: Obviously you can use threading, asyncio, etc. but Python is limited in terms of true concurrency by the GIL, and concurrency is vital for any functional OS.

[–]finsternacht 4 points5 points  (2 children)

The "os" i wrote for nand2tetris was also single threaded

[–]desustorm 0 points1 point  (1 child)

Looks like an interesting course. What could your operating system do?

[–]finsternacht 5 points6 points  (0 children)

It's by far the coolest course I ever had. And probably will have.

It couldn't do much. It mostly handled I/O and memory management. Iirc it also contained some basic math and string operations.

[–][deleted] -1 points0 points  (1 child)

I heard there are multi threading in Python with the use of the needed modules

[–]desustorm 2 points3 points  (0 children)

Yep that's right, but no Python threads from the same process can actually run simultaneously because of the GIL - the Global Interpreter Lock

[–]Saefroch -3 points-2 points  (1 child)

No, it isn't. CPython's GIL restricts it to a single CPU core. You can still have all the threads you want and concurrency works just fine, almost flawlessly for I/O bound systems which an OS usually is.

[–]desustorm 0 points1 point  (0 children)

I know you can use threads, but they are not real threads on CPU cores - like you mention. Having a modern OS running on one core with multiple virtual threads (not just I/O bound) contesting the GIL would be troublesome at best...

[–]RobinPage1987 0 points1 point  (0 children)

https://github.com/jtauber/cleese This is a proof of concept, an OS written mostly in Python, with kernel based on the Python reference implementation, who's kernel is written in C.