16

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!

menjaraz
  • 7,551
  • 4
  • 41
  • 81
Sylar
  • 161
  • 1
  • 1
  • 3
  • Concerning writing it in python: what machine are you going to run it on? I haven't heard of either a python to native compiler or a chip with support for python bytecode... – dmckee --- ex-moderator kitten Sep 06 '10 at 04:03
  • 1
    See also: [Barest Bare Boned Operating System Possible](http://stackoverflow.com/questions/263926/barest-bare-boned-operating-system-possible). Several good suggestions for models in there. – dmckee --- ex-moderator kitten Sep 06 '10 at 04:10
  • possible duplicate of [Is it possible to create an operating system using Python?](http://stackoverflow.com/questions/10904721/is-it-possible-to-create-an-operating-system-using-python) – Anderson Green Jan 17 '14 at 19:41

11 Answers11

17

Scale this down a lot. I would recommend looking at one very small piece of an operating system that you would want to do, perhaps parallel processing. There is no feasible way you will be able to write an entire operating system in under 500 hours, let only 5000 hours. The real question is is this for an undergraduate course or a graduate course? The answer to that will greatly reflect what is needed to pass.

Adding
Grab a book on a topic about the operating system that interests you and focus intently on that for 3 months and you may just produce something that is good. Operating systems may seem like they don't do much on the outside, but think of it this way Windows has ~50 million lines of code.

Woot4Moo
  • 23,987
  • 16
  • 94
  • 151
  • 7
    Tanenbaum's book *Operating Systems* is a must read. – Alexandre C. Sep 04 '10 at 19:01
  • 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 Sep 04 '10 at 19:03
  • 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... – L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ Sep 04 '10 at 19:37
  • 4
    @Longpoke: Linux is just a kernel, Windows is a complete operating system. – Alon Gubkin Sep 04 '10 at 19:44
  • @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". – L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ Sep 04 '10 at 19:46
  • @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). – Sasha Chedygov Sep 05 '10 at 00:04
  • @Alon: http://www.ragestorm.net/blogs/?p=255 – rwong Sep 05 '10 at 06:31
  • @SashaChedygov I'd say that's pretty far from well-defined. It only makes sense to you because you already have a picture of what that means. Would you consider the BIOS functions to be a kernel? That would make having your own OS pretty simple, just... don't write a single line of code. Simple, eh? :)) – Luaan May 26 '15 at 14:31
10

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
  • 6,062
  • 1
  • 23
  • 51
  • lol good luck writing an OS in pure C with no assembly... – L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ Sep 04 '10 at 19:48
  • @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 Sep 04 '10 at 19:58
  • 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 Sep 05 '10 at 05:10
  • @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 Sep 05 '10 at 06:03
3

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
  • 31,821
  • 4
  • 39
  • 33
  • 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 Sep 04 '10 at 18:47
  • 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 Sep 04 '10 at 18:50
  • want and need are two far different concepts. – Woot4Moo Sep 04 '10 at 18:51
  • There are already many operating systems written in Python, you only need some bootstrap code unless you have a python bytecode processor. – L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ Sep 04 '10 at 19:50
  • 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 Sep 04 '10 at 20:11
  • 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 --- ex-moderator kitten Sep 06 '10 at 04:06
  • It is possible: http://stackoverflow.com/questions/10904721/is-it-possible-to-create-an-operating-system-using-python. But you need the interpreter. – skywalker Mar 17 '16 at 17:15
1

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
  • 7,547
  • 2
  • 28
  • 33
1

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
  • 77,689
  • 9
  • 166
  • 211
  • 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 Sep 05 '10 at 05:02
1

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.

user281693
  • 615
  • 2
  • 8
  • 20
  • 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 Oct 30 '10 at 15:02
  • 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... – user281693 Oct 31 '10 at 07:03
0

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 (from 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 doing 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 and discouraging.

All that said. Best of Luck :)

Bloxy Craft
  • 131
  • 1
  • 3
  • 12
loxxy
  • 12,990
  • 2
  • 25
  • 56
0

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
  • 573
  • 2
  • 8
0

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.

Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
0

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.

Community
  • 1
  • 1
Ming-Tang
  • 17,410
  • 8
  • 38
  • 76
  • 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 :) – L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ Sep 04 '10 at 19:52
  • 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 Sep 05 '10 at 05:07
-3

Buddy, here is the answer you have been looking for:

Writting an Operating System is not different than writting any other application, actually it is far easier than writing any other code for the reason an Operating System is an ALL-PURPOSE software or what is meant as a platform... and you know it!.

All of the previous asnwers are EXTREMELY USEFUL!, and ALL OF THE PREVIOUS INCLUDING THIS ONE WILL HELP YOU IN CODING YOUR O.S. actually in less than three months.

Please, try to be objective and get rid of negative answers (that is just mindblocking...)

A Software Developer actually CODE EVERYTHING that comes to his mind! (in my case I was a SUPERB software developer until I had a brain accident and suffered hypoxia for a considerably period... not want to talk further about it... me traumatized...)...

Let's speak clear:

If you want to build an O.S. do the following and start TODAY!:

  • Define if you want to write a SHELL or if you want to write a CORE O.S.;

  • Plan main functions of the O.S., processes, etc.;

  • Choose the level you want to build it on:

    • VERY LOW LEVEL (Assembly Language required and MEMORY, CPU, AND HARDWARE RESOURCES KNOWLEDGE REQUIRED ALSO -NOT TO BE ACQUIRED IN MERELY THREE MONTHS... OH NO!...)...

    • Medium Level (Here you can use the STANDARD solution, that is C programming Language!);

      • High Level (This is the level you may want to use Python, it means you will use ALL of the same resources and shells you operating systems offer to you, whether it is any Linux Distribution, or a UNIX(R), Windows(R), CP/M(R) or any other known up to date);

Because of the time required for you to build it I must assume you are delivering a College work to earn credits... and yet in case you work for a Corporation or in case you are self employed or your own C.E.O., you must have resources assigned to this project... I will assume you are building it for a Academic's!.

Imagine you are writing a shell, that will ease the start-up of your work, and while you are writing the shell your mind should be drawing the real core of it, along with the addressing and along with the lowest level routines...

I think you may know MS(R)-DOS(R). The version 3.3 is one of the easiest and enriching (pedagogically speaking) Operating Systems ever designed and published by Microsoft(r) Corp. Please, be creative, DO NOT CLONE IT, just inspire your mind on it, and then build something your Professor or end-consumer will admire and enjoy!.

Do not forget we are in the age of Graphical User's Interface, so do not go into texting, although ASCII is still the most beautiful expression of computer age, you can play with both interfaces.

Once you work this from Top to Dowm you will find out how easy it is to build routines in High Level language, and once you build it, and debug it, may be you will speed up a CORE os. that is: Bootstrapping, Memory management, etcetera...

Do not get to involved in dealing with interruptions or you may end up loosing you enthusiasm INMEDIATELY!... leave the UNDERGROUND O.S. to deal and take care of the interruptions.

In less than three months you will have your first prototype, and then you need to make it work good (To Debug it, I mean!). Exceed yourself!.

If you work SOLO, you will need to write a manual, IT TAKES CONSIDERABLY PRECIOUS TIME YOU DO NOT WANT TO LOOSE... My advice (please, do not laugh, I used this technique and it made today's Magnate's earn BILLIONS) WRITE DOWN IN PAPER, HANDWRITTEN, ALL OF THE DOCUMENTATION (THIS IS BECAUSE YOUR FINE MOTRICE COORDINATION IS FASSST! AND EVEN IT WILL NOT EQUAL THE SPEED OF YOUR THOUGHTS IT IS A HARD COPY TO DELIVER TO A WELL PAID ASSISTANT TO TYPE IT INTO A COMPUTER AND EDIT IT MARVELOUS -MAYBE A .PDF WITH ILLUSTRATIONS, ALONG WITH A VIDEO WILL SHARPEN AND DELIGHT THE EYES OF THE END-CONSUMER!.

Remember, the build up of the first month must be actually a SHELL of the basic functions a BASIC operating system must deliver to the user:

  • Commands Processor;
  • File Directory listup;
  • Create/Edit and Delete files;
  • Create/Edit and Delete Directories;
  • Accessing drive units (floppies, Compact Discs, HardDrives, Flash Drives, etc...);
  • Update and Display of information through the screen!;

I would focus mainly in the previous, and then ANYTHING else comes up easily through the creation of enriching routines (trust me this phase is addictive and you will have NO MORE life when you reach to this poit for you will be married to this project and you will never leave it anymore), do not fear, it wil work!.

Present your Operating System, and if your expecting upcomming funds show up, or if your expecting grade gets the higher rated you expect, you may want to keep enlarging your project and then build it into a more solid, robust and steady application!.

Just imagine yourself using this platform as a plaintiff for any kind of hardware you may want to work with: ROBOTS, AUTOS; AIRPLANES; REMOTE CONTROL; ETC...

I know you will enjoy this assignment and I know you will entertain yourself greatly! Only a real programmer has this kind of ambitions!

God bless America!

KnowBuddy