473,836 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python Operating System???

Hello. I recently came across a free operating system called Unununium (or
something like that) and it was developed in Python and Assembly.

Now, I have been looking for a way to make an operating system for a long
long time and the only possibilities I could find were C++ and assembly. I
don't mind assembly so much if I don't have to use it very often. But C++ is
so complicated and errors are pretty much impossible to find in the code for
me.

So, I was wondering if it would be possible to find a bootloader that loads
a python file at startup or something...

Is there an example somewhere of a Python OS?

Thanks!
Jul 18 '05
32 9815
"Roose" <b@b.b> writes:
An OS is NOT an application. It is a completely different kind of program.
Do you guys understand the difference between user and kernel mode? Do you
know what address spaces and hardware interrupts are? Python is not
equipped to handle these things. You would end up doing so much in C
extensions that it could barely be called Python.
You'd need some library functions to let Python access device registers
and you'd need some low level code to dispatch interrupts into Python code.
I am not trying to be insulting... but unless someone would like to educate
me otherwise, the idea of an OS written in Python is almost ludicrous.
Is an OS written in Lisp also ludicrous? Because it's been done.

When Unix was first written, people thought implementing an OS in C
was ludicrous. Everyone knew OS's had to be written in assembler.
Also I am no threading expert, but I would imagine it would be very hard to
write a task scheduler in Python given that it has the whole GIL thing. (As
I said that isn't my domain of expertise but I'm sure someone here could
expound on that.)


The GIL is not part of the Python language. It's just an artifact of
one particular implementation.
Jul 18 '05 #21
So how would I make an OS Shell?
Jul 18 '05 #22
Paul Rubin wrote:
When Unix was first written, people thought implementing an OS in C
was ludicrous. Everyone knew OS's had to be written in assembler.


Actually, when Unix was first written that belief was entirely
correct, and OSes *did* have to be written in assembler.

That is, pure C did not have the capability to handle all
that was required. I recall it taking a good decade before it
became *common* to find C compilers with, for example, @interrupt
support to let the compiler generate code that properly saved
all registers and used RTI instead of RTS (or whatever it might
have been called one one's particular flavour of CPU).

Now, once you added a few tiny interrupt handlers, and some context
switching (stack manipulation) routines, pretty much everything else
*could* be done in C, but that doesn't invalidate the point.

I think it's safe to say that none of pure C, pure Lisp, or pure Python
are really capable of being used as the *sole* language to build
an operating system.

It's also safe to say that this is a largely irrelevant point.
It would probably only be of academic interest to try to do
something like that. Any practical attempt would not think more
than twice of resorting to a little "glue" in assembler or in
the form of "canned" byte sequences built by hand and stuck
into the appropriate places in memory...

-Peter
Jul 18 '05 #23
Peter Hansen wrote:
Paul Rubin wrote:
When Unix was first written, people thought implementing an OS in C
was ludicrous. Everyone knew OS's had to be written in assembler.

Actually, when Unix was first written that belief was entirely
correct, and OSes *did* have to be written in assembler.


*nods*

That is, pure C did not have the capability to handle all
that was required. I recall it taking a good decade before it
became *common* to find C compilers with, for example, @interrupt
support to let the compiler generate code that properly saved
all registers and used RTI instead of RTS (or whatever it might
have been called one one's particular flavour of CPU).
If my memory serves me, you are entirely correct.

Now, once you added a few tiny interrupt handlers, and some context
switching (stack manipulation) routines, pretty much everything else
*could* be done in C, but that doesn't invalidate the point.
*nods*

I think it's safe to say that none of pure C, pure Lisp, or pure Python
are really capable of being used as the *sole* language to build
an operating system.
*nods*

It's also safe to say that this is a largely irrelevant point.
It would probably only be of academic interest to try to do
something like that. Any practical attempt would not think more
than twice of resorting to a little "glue" in assembler or in
the form of "canned" byte sequences built by hand and stuck
into the appropriate places in memory...

-Peter


Indeed indeed. Once must remain focused and ask oneself what he/she is
attempting to achieve. In all likelihood, a little asm/c/python glue
work won't hurt the objective, especially given that doing otherwise
would entail a very _low level_ reworking of Python that would take as
much and likely more effort and skill than to resort to asm/c when
Python falls incapable. One could do a Python-Lisp OS w/ Lisp used for
the Python incapable areas, but you would near entirely loose the
benefits of Lisp in that respect--- it would have to be so low-level,
could you call it Lisp? (A question someone else here posed in this
thread.)

- Arich
Jul 18 '05 #24
Is an OS written in Lisp also ludicrous? Because it's been done.


Can you point me to this? I'd like to see how "truly" Lisp it is.

My first guess would be -- not very. And I'd like to install it on my PC.
Jul 18 '05 #25
Well can you describe what kind of things you want to do exactly?

My guess is you are not out to develop a new algorithm for virtual memory or
task scheduling.

There are many parts to an OS shell. An example is the command line, i.e.
bash and the like in Unix, and cmd.exe in Windows. In Windows, Windows
Explorer could be considered part of the shell, as well as the start menu
and all that user-specific stuff.

Basically you need to pick your OS, and then find out what the API to
program the shell to would be. e.g. in Windows you would do it with the
Win32 API. This will let you do things like delete and create files,
interact with user structures, the registry, etc.

OR, as a first stab -- I would just write a prototype. i.e., don't tie it
to a real OS. Just pretend you have your own "users", your own "file
system", your own display space, etc. This will help you get a much better
idea of what you want to do.
"David Brown" <da***@graydrag on.net> wrote in message
news:10******** *****@corp.supe rnews.com...
So how would I make an OS Shell?

Jul 18 '05 #26
My experiment, Cleese, was making progress before I got distracted by
other things.

The approach was a micro-kernel in C made up of the CPython bytecode
interpreter with the file-related calls to libc ripped out and some
bare-metal port read/writes and memory operations exposed to Python as
built-in functions.

Everything else could then be written in pure Python. Dave Long was
able to write a VGA driver in Python and an implementation of Sokoban
that used it. You could then boot your machine to Sokoban :-)

I should probably get back to it at some stage.

see http://cleese.sourceforge.net/
James Tauber
http://jtauber.com/blog/

Jul 18 '05 #27
"Roose" <b@b.b> writes:
Is an OS written in Lisp also ludicrous? Because it's been done.
Can you point me to this? I'd like to see how "truly" Lisp it is.


http://en.wikipedia.org/wiki/Lisp_machine
My first guess would be -- not very. And I'd like to install it on my PC.


Although written with federal funds at a university, it was never
released to the public, but was instead offered for sale from some
companies. The conflicts over this led to the birth of the free
software movement.

Also, it was never intended to run on PC's (which didn't exist at that
time). It needed special hardware that was built for the purpose of
running Lisp. Lately there are people trying to program PC's to
simulate the Lisp hardware and to get the Lisp Machine software
released (now that the commercial market for it has long since dried
up). However, both of those projects have a ways to go.
Jul 18 '05 #28
On Sat, 08 Jan 2005 08:28:12 GMT, "Roose" <b@b.b> wrote:
I am not trying to be insulting... but unless someone would like to educate
me otherwise, the idea of an OS written in Python is almost ludicrous. As I
said, I think you might mean an OS SHELL, which would be a reasonable
(although maybe unconventional) thing to write in python.


That's a crazy idea I once had - what if a user could run Python as
a shell of Linux/other free U**x, and access every single subsystem
and piece of data in the object-like manner?

Sure, things like pipes and immediate access to files without having
to open() them and the whole filesystem hierarchy would have to be
added. Quite a lot of plumbing work would have to be done,
but once it were done, it would be like an object operating
system, everything organized nicely in predictable object hierarchies
with dot access.

System scripts would no longer be a mess that breaks every now and
then depending on slight differences in filesystem hierarchy. Python
dictionaries with their ability to quickly bind names to various
objects would make it possible to keep such hierarchy stable, even
with data moving around on different physical disk partitions and
folders. Instead of saying:

# cp /etc/postfix/main.cf /mnt/floppy

the user could say e.g.

..>>> copy system[config][mta] floppy

or

..>>> copy system.config.m ta floppy

In an "object system" like Python it could be reasonable to
consider writing a class that would implement at least a
subset of generic interface to the equivalent functionalities
of various MTAs. Maybe. With traditional filesystems trying
smth like that is not really reasonable, because 99% of
the time it would work, but 1% of the time it would fail
and that 1% would ruin the whole venture, as handling
low-level OS complexity for a non-tech user has to be
more reliable than that - in two cases when I installed
Linux for free for someone the installation was finally
deleted by those users because the desktop shortcuts
to devices like floppy and CD ultimately failed to work
for some reason and using 'mount -t iso9660 ...' was
not an option that they would consider learning and
using really.

Think about all the potential! On top of clean, stable
system interface a user could use map, filter and reduce
functions on various system objects. Handlers for
files with known structure could be written, so
dot or list or dictionary access would allow manipulating
data inside the files, like file[rownumber]='spam', or
spreadsheet_fil e['A2', 100]. Or you could issue commands
like browser.go('som ewhere') or desktop.edit('h ello.txt').

I was considering writing smth like this myself but it's
way over my head re low-level OS and kernel stuff. :-(

IMHO Linux problem has long been that in its lower level
interface (above kernel and below GUI) is way too much like
traditional UNIX. Sure someone with sysadmin experience
can use it - but in my experience it's way over the head of
the typical user. Trying to teach them about mknod and
/dev/* hierarchy is hopeless and too hard for them.

--
It's a man's life in a Python Programming Association.
Jul 18 '05 #29
Paul Rubin:
Lately there are people trying to program PC's to
simulate the Lisp hardware and to get the Lisp Machine software
released (now that the commercial market for it has long since dried
up). However, both of those projects have a ways to go.


There's a video of someone demoing how to use a Lisp Machine at
http://lemonodor.com/archives/000103.html

Andrew
da***@dalkescie ntific.com

Jul 18 '05 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
5640
by: John McMonagle | last post by:
Is there a python module which can determine an operating system's default web browser application. I would like to use it in the following context: I have a GUI application where all the documentation is written as html pages. I wish to have these html help pages open in the default browser when selected from the application's Help menu If python can determine the path to the default browser, I can then just spawn it.
3
2406
by: PythonUsr | last post by:
Although I know for a fact that an Operating System can be written in Python, I need to ask some questions to the more advanced users of Python. Uuu and Cleese are two operating systems that were / are written in Python. Does anyone use them? If so, how do they function / feel? Do they have a graphical mode and a command line mode, such as Linux does? How hard would it be to write a full blown bootable operating system in Python? With...
7
23791
by: Ian F. Hood | last post by:
Hi In typically windows environments I have used: if 'Windows' in os.environ... to prove it, but now I need to properly support different environments. To do so I must accurately determine what system the python instance is running on (linux, win, mac, etc). Is there a best practises way to do this? TIA Ian
0
9657
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10532
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10577
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5812
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4443
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4003
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.