Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operating System from scratch [closed]

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!

like image 400
Sylar Avatar asked Sep 04 '10 18:09

Sylar


People also ask

What is a closed operating system?

Closed-source operating systems use code that is proprietary and kept secret to prevent its use by other entities. Traditionally, they are sold for a profit. Open-source operating systems use code that is freely-distributed and available to anyone to use, even for commercial purposes.

Is it possible to make an operating system from scratch?

Few programmers ever attempt to build an OS and many of those who do make the attempt never produce a functioning system. However, if you do make it all the way to the finish line and produce a functional operating system, you will have joined an elite group of top-flight programmers.

Is Linux a closed operating system?

Linux® is an open source operating system (OS). An operating system is the software that directly manages a system's hardware and resources, like CPU, memory, and storage. The OS sits between applications and hardware and makes the connections between all of your software and the physical resources that do the work.

What is an example of closed source software?

Some examples of closed source software are Skype, Google earth, Java, Adobe Flash, Virtual Box, Adobe Reader, Microsoft office, Microsoft Windows, WinRAR, mac OS, Adobe Flash Player etc.


6 Answers

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.

like image 76
Woot4Moo Avatar answered Sep 29 '22 05:09

Woot4Moo


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

like image 37
rwong Avatar answered Oct 02 '22 05:10

rwong


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".

like image 42
Jim Brissom Avatar answered Oct 01 '22 05:10

Jim Brissom


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.)

like image 45
John R. Strohm Avatar answered Sep 30 '22 05:09

John R. Strohm


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?

like image 34
supercat Avatar answered Sep 28 '22 05:09

supercat


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.

like image 36
user281693 Avatar answered Sep 29 '22 05:09

user281693