Reimplenting Linux Kernel in Python

Mike Meyer mwm at mired.org
Thu Oct 14 17:37:52 EDT 2004


mike at hobbshouse.org (Michael Hobbs) writes:

> Maboroshi <nobody at hotmail.com> wrote:
>> My question has to do with python and linux - I was interested in 
>> finding out what it would take to reimplement the Linux Kernel in python 
>> basically just taking the source code from linux and rewriting it in 
>> python Would this idea make sense to do - if so what would be the 
>> benefits of doing this and in what way would this not be a good idea
> I had once given serious thought to what it would take to write an OS only
> in a high-level language. (Standard ML was my language of choice at the
> time.) The short answer is, no, it can't be done with Python as it currently
> stands. 

But it can be done. It *has* been done.

> First, you would need a Python compiler that can compile Python programs to 
> machine code. Otherwise, what would you write your interpreter in? Python?
> What would you write the interpreter's interpreter in? It can't be Python
> all the way down. (Turtles are a different story, though. ;)

If you've got a Python compiler that generates machine code, you most
certainly *can* write your Python interpreter in Python. That's the
way most LISP systems are built.

> Second, in order to communicate with hardware, you would need modifications 
> to the Python language so that you can read and write bytes to specific
> memory locations. You would also need to be able to signal interrupts. Plus,
> you would also need to be able get the exact memory location of functions,
> in order register interrupt handlers.

Actually, you don't need those modifications to Python. What you need
is a module written in something other than Python that lets you do
all those things. All unix systems I'm aware of require code in
something other than C to let them do things that C can't do. Nothing
wrong about this - it's just the nature of the beast.

      <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list