views:

331

answers:

10

I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python.

I have a few limitations:

  1. I have only 3 months.
  2. I want to do it in Python.
  3. I can put in say 20-30 hours every week into it.

I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations?

Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS)

If the idea is not feasible, can anyone tell me how much do I need to scale down my idea?

Any help is much appreciated!

+10  A: 
Woot4Moo
Tanenbaum's book *Operating Systems* is a must read.
Alexandre C.
I have the operating system book with the dinosaurs on it, I can't recall its name at the moment. EDIT: Operating System concepts
Woot4Moo
uggh, get over it, writing an OS isn't rocket science. Plus you can use a RISC processor to maintain sanity. Linux only has ~8 million lines of code... and most are probably just support for thousands of different types of hardware...
Longpoke
@Longpoke: Linux is just a kernel, Windows is a complete operating system.
TTT
@Alon: well now that you mention it, a kernel isn't a very well-defined term... OP should mention what he means by an "operating system".
Longpoke
@Longpoke: I'd say it's pretty well-defined. It's "a bridge between applications and the actual data processing done at the hardware level" - [Wikipedia](http://en.wikipedia.org/wiki/Kernel_%28computing%29).
musicfreak
@Alon: http://www.ragestorm.net/blogs/?p=255
rwong
+1  A: 

I don't get how you think you can write an operating system in Python. You need native code to at least load an interpreter during bootup, not to mention hardware communication, drivers etc., all of which would be nearly impossible to do given current Python interpreters when running on a bare machine. I'm also pondering if you are aware that you'd have to port a given Python interpreter to compile and run without an underlying operating system, which alone would keep you busy for a time.

It's good that you are ambitious, but I honestly think you could not even finish the basic operating system, let alone "some very basic apps running".

Jim Brissom
The question wasn't about limitations of Python. It was more so about the ability to write an operating system in 3 months and the issues that were facing that task.
Woot4Moo
From what I've read, it says: "I want to do it in Python [...] how feasible is the idea?". In my book,writing a whole operating system in Python is pretty much impossible, so just maybe this is worth mentioning...
Jim Brissom
want and need are two far different concepts.
Woot4Moo
There are already many operating systems written in Python, you only need some bootstrap code unless you have a python bytecode processor.
Longpoke
I wouldn't say many. But I am willing to admit that I probably should've added writing one "in pure Python" is impossible (impossible as in nowhere near practical/insane). Alas, I believed when I mentioned that you'd need native code to fire up a matching Python interpreter in my answer, I thought to get the concept across.
Jim Brissom
I am not aware of one that supports python, but machines have been built in the past to support the byte code of an originally "abstract" virtual machine or to provide an easier native target to compile to. See also lisp machines and p-code machines. And I recall some talk in the late '90s about implementing much of the JVM in hardware, though I am not sure how far people got with that.
dmckee
A: 

I know...the idea is pretty bubbly. Even I had this experience (for a while :p).

But Its really when you dig into it, that you realize how big a word you just said. I am in no cost gonna say that you can't make an OS. Cause I believe in keeping unachievable dreams. Cause doing this might help you learn faster.

Anyways, PYTHON? na. Go for C.

  • Read (principles) : System processes & services.
  • Write (code) : Practice & get used to code. Use language as a tool, not a skill.
  • Learn (frm mistakes) : This is the best thing. You will have an OS if you learn frm dem.

I would however suggest not to waste your 3 months, googling how to create an OS in 3 months & rather Also dun things things like which say the job you are trying is a piece of cake. eg : http://linuxologist.com/1-general/create-your-own-linux-distro/ Even that heading is misleading n discouraging.

All that said. Best of Luck :)

loxxy
Perhaps one would look into writing an OS using Java as a unique challenge
Woot4Moo
Who knows.....Mr. Oracle ate the sun. If they chew down moon too, they could just end up shipping Java VM along with PC'S n their Solaris :)
loxxy
Wait a sec, forgot to throw out the bone from oracle's dinner, Off you go ogle.
loxxy
There are already operating systems written in Java and Python...
Longpoke
Unununium, the only thing in python. Which probably still doesn't work for most other than network services. The JavaOS.....obviously. But the question here is, if we are to develop it...I surely might try only if my idiotic comments came true.
loxxy
+2  A: 

Does your professor require a "low-level" component in the project? For example, anything that deals with the hardware or the instruction architecture. If so, your professor will not allow you to do the project in Python. The project must be written in C and assembly. And you will invariably be working on modifying the Linux kernel.

However, nowadays Operating System is no longer confined to the low-level aspect. Virtualization, database, parallelization are all built on top of the Operating System. If your professor is "old school" then he/she may not consider those new topics to be part of Operating System. So, you may need to bring some sample ideas to your professor and seek clarification.

Whether to go into low-level, as some have suggested, depends entirely on the professor's educational goals.

  1. To teach basic concurrent programming constructs, such as events, semaphors and mutex. This can be taught by writing some multi-thread applications. It is arguably too easy as a goal for an OS class. Nevertheless, this is in fact the most "marketable" skill you will get from the class.
    • A variation on this theme is to teach how to "use" a particular flavor of OS API.
  2. To teach how to write applications that make efficient use of the operating system. This may require you to implement some entry-level OS-related algorithms inside a "simulated OS project" (say, in Java or Python, could also be in C++). Each aspect can be studied in separate projects/simulators, without using a full-blown OS.
    • For example, to teach how to use the file cache efficiently, it is necessary to make students play with a "toy" file cache using a simple algorithm.
  3. To teach the hardware aspect of operating system (including the ugliness of it), namely, how it interacts with the instruction set architecture and hardware I/O. This is usually done with "embedded system", with a small prototyping board.
  4. To teach real-world algorithms used inside modern operating system. This will require lots of paper reading, as well as implementing a non-trivial algorithm inside a real Linux kernel. This level is appropriate for graduate studies.

A good project would include one or more of:

  • Input / Output
  • Storage
    • Deciding what to cache / predicting what to pre-load
  • Starting / managing / logging tasks (processes, threads or Python functions), locally or remotely
  • Managing resources
    • Require each process to give estimates of how much peak memory will be used, and to report a "progress" percentage regularly throughout their execution, which can then be used together to make estimates about resource usage
  • Communication
  • Concurrency

A project that does not directly interact with hardware, but would still be good project, will be:

  1. If your project provides an abstraction of the operating system to the apps that will run "inside" your project
    • In other words, the "apps" rely solely on your "operating system project" for their I/O, storage, task management, resource, communication needs
  2. Your project makes good (efficient, measurable) use of the real operating system (Windows, Linux etc)

Then it will be a good Operating Systems project, regardless of the language used.

I would suggest implementing your own memcached, map-reduce or a simple version control system as good project examples.

Edited: removed ranting

rwong
lol good luck writing an OS in pure C with no assembly...
Longpoke
@Longpoke: it depends on the level of the OS. OS that run on hardware / instruction set architecture, yes. Hardware breakpoints on virtual page, yes. Execution protection, etc. DMA, ...
rwong
Yes. The control system seems like a fitting idea, but I didn't understand your point, "If your project provides an abstraction of the operating system to the apps that will run "inside" your project,"Can you explain a bit please?Thanks a lot for the help.
Sylar
@Sylar: that the "apps" rely solely on your "operating system project" as to all of their needs for I/O, storage, task management, resource management, communication, and doing this concurrently. In other words, like a middleware between the "apps" and the real operating system.
rwong
Okay. Got it. Thanks a lot. Much appreciated.
Sylar
+1  A: 

You probably can't do this in one semester.

If you want to take a swing at something similar, read up on the Solo operating system, built by Per Brinch Hansen and his students at Caltech. They wrote the whole thing in Concurrent Pascal, a Pascal derivative developed by Brinch Hansen.

The source for Solo is available in Brinch Hansen's "Architecture of Concurrent Programs". (link is to a PDF of the entire book) Your professor SHOULD have a copy. Your university library should have a copy. Occasionally, copies show up on Amazon.

Or you could do a version of Brinch Hansen's RC4000 Nucleus. (Google is your FRIEND.)

John R. Strohm
A: 

Learn from what other people have done in the world of operating systems. In addition to the books mentioned above download the vanilla linux kernel source and start exploring it: http://www.kernel.org/ . Robert Love's book on the Linux Kernel, Linux Kernel Development, will give you a great overview of the all the pieces involved in the Kernel.

A major highlight would be how the O(1) scheduler works in the new kernels since scheduling is just one of the many and major concerns that come into play when writing an Operating System.

MadcapLaugher
A: 

Developing an operating system in Python is possible. However, you might want to choose C or Assembly because there's an huge code base developed in those languages.

TTT
A: 

lol, it reminds me this

http://www.getacoder.com/projects/programming_c_87390.html

Making a complete OS like Windows or Mac or Linux is as hard as making a MMORPG.

Maybe you should make the simplest OS that lets you boot successfully and run some simple command line scripts, like how DOS works, but in Python and runs Python.

SHiNKiROU
he clearly doesn't want to make a "full os" as it's a 3 month project... yeah that would be awesome to make a kernel and demonstrate it by booting to a Python shell, good idea :)
Longpoke
The link was a good read. Thanks a lot for that. I'll defo. need those if I go ahead with this. So, if I do what you are saying, its basically, the OS would boot up into a text based shell ( no GUI ) and somewhat execute commands like the terminal in linux and/or DOS in Windows. Right? Thanks for the help
Sylar
+1  A: 

You could probably code a small embedded-system OS in the timeframe you indicate, using concepts that are over a decade old. Many newer operating systems require many more complicated scheduling and memory-management heuristics than would be typical in a small embedded OS; designing an entire modern OS would not be a practical single-person project, but one might be able to do something interesting with some subsystem of it. I personally think there's some room for improvement in flash file systems, but I don't know what your prof would think. What is your prof really looking for?

supercat
My prof. isn't looking for anything specific, He wanted to choose are own ideas but it should be good. And personally for me, I want something that would score the best project.
Sylar
+1  A: 

In our university we have operating systems course where we too are supposed to develop something on linux. Not entire OS. We did our own scheduling policy and file system for linux. But this will be done in C since linux is in C.

hey I too have opted a file system project using C in Linux. Could you give some pointers where to start ? I am kind of lost, do I need to understand the linux kernel ?
Abhinav Upadhyay
I dont think its feasible to understand the entire kernel code. Depends on how much time you have. We had about 3 weeks for file system project and 10 weeks overall for the course. So before we implemented file system we did other projects which gave us an understanding of the kernel. You may look at ramfs and ext3code. Linux books will have chapter on File systems. You can follow them. Few things you need to understand: superblock, inode table structure, how to register a file system...