How to create a basic operating system?

Programming, for all ages and all languages.
rsmahanti
Posts: 5
Joined: Thu Oct 07, 2010 9:59 pm

How to create a basic operating system?

Post by rsmahanti »

I got a project to create a basic operating system which will just boot up and can run a calculator in it. I have 28 days to complete the project. I have absolute no idea about how to do it? What I know is basic C programming. Can anybody give me any idea to start with? Any sample piece of code or anything which can help me. Please don't advise me t read a thousand page book. Neither I have money to purchase a book nor I have time to read 1000 page ebook. I want to know
1) What is required to boot up a system? How much code I have to do?
2)Is it possible to run a calculator on a very basic operating system? If possible, how?
3)Can I run his type of OS in vmware? If no, what Extra I have to do to run it in vmware?
4)Is it really possible to do it in 28 days?

The hardware I am going to use is typical pc hardware we use for windows or linux machine.
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: How to create a basic operating system?

Post by thepowersgang »

May I point you to the wiki.

1. See the barebones tutorials on the wiki.
2. Yes, I'll leave the implementation up to you.
3. Yes, VMWare is exceptionally similar to a real PC (the higher level video interface is a little different to actual hardware, but basic OSs generally don't care about that)
4. It's doable, but it may be tight. It depends on how well you understand things.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
rsmahanti
Posts: 5
Joined: Thu Oct 07, 2010 9:59 pm

Re: How to create a basic operating system?

Post by rsmahanti »

@thepowersgang : Thanks. I will read the wiki. Let's see how much I can understand.
rsmahanti
Posts: 5
Joined: Thu Oct 07, 2010 9:59 pm

Re: How to create a basic operating system?

Post by rsmahanti »

Can somebody explain the overall procedure for me once? Like to boot up an operating system, I have to code for grub and kernel and what else? If I don't have to code for grub then what I have to do?
User avatar
piranha
Member
Member
Posts: 1391
Joined: Thu Dec 21, 2006 7:42 pm
Location: Unknown. Momentum is pretty certain, however.
Contact:

Re: How to create a basic operating system?

Post by piranha »

Grub boots kernel.
Kernel initializes itself, loading GDT, IDT, interrupt systems, etc.
Kernel starts a keyboard driver.
Kernel runs a calculator program, which you can implement directly in the kernel.

Program yourself a basic kernel that says hello world (see the barebones on the wiki).
Program yourself the GDT and the IDT and etc interrupt stuff (see the wiki [interrupts, gdt, idt, isrs, keyboard]).
Get the keyboard input working (see wiki [keyboard]).
And then write a calculator.

Its doable in 28 days, providing that you are motivated enough to try. If you cannot find the information in the wiki that details the process, you don't have much hope of doing this in 28 days. However, it is doable, but since we don't know the extent of your programming skills we can't give a good estimate on how feasible it is.

Good luck,

-JL
SeaOS: Adding VT-x, networking, and ARM support
dbittman on IRC, @danielbittman on twitter
https://dbittman.github.io
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How to create a basic operating system?

Post by JamesM »

Hi,
rsmahanti wrote:I got a project to create a basic operating system which will just boot up and can run a calculator in it. I have 28 days to complete the project. I have absolute no idea about how to do it? What I know is basic C programming. Can anybody give me any idea to start with? Any sample piece of code or anything which can help me. Please don't advise me t read a thousand page book. Neither I have money to purchase a book nor I have time to read 1000 page ebook. I want to know
1) What is required to boot up a system? How much code I have to do?
2)Is it possible to run a calculator on a very basic operating system? If possible, how?
3)Can I run his type of OS in vmware? If no, what Extra I have to do to run it in vmware?
4)Is it really possible to do it in 28 days?

The hardware I am going to use is typical pc hardware we use for windows or linux machine.
Here's a bit of a shameless plug: http://www.jamesmolloy.co.uk/tutorial_html. I wrote some tutorials several years back that should talk you through much of what you want to do. You shouldn't need paging or anything like that for a simple calculator - just a C program writing to the screen, taking interrupts will do. See up to section 5.

Remember that if this is an assignment, be VERY careful not to plagarise works found on the internet. I don't really mind if you take my code verbatim, as long as the copyright is maintained, but I'm sure your lecturers will take a rather less bright view of you not doing your own work!

Read the tutorials by all means, but I wouldn't submit a carbon-copy of the resulting code.

James
User avatar
qw
Member
Member
Posts: 792
Joined: Mon Jan 26, 2009 2:48 am

Re: How to create a basic operating system?

Post by qw »

There is also the BrokenThorn Operating System Development Series.
Gaidheal
Member
Member
Posts: 51
Joined: Mon Oct 04, 2010 6:23 pm

Re: How to create a basic operating system?

Post by Gaidheal »

I have very little to add, just echoing what others have said, really; if you can get a very simple kernel written, use GRUB to load it and start it and then a simple calculator application (your course may expect its implementation to be separate from your kernel, read it to be sure), you'll be done, by the sounds of it.

The code for a calculator is not especially challenging, GRUB is pretty well documented, so the real challenge is writing a basic kernel; in this regard James's excellent tutorial should help you well along the way, in concert with the Wiki to get the theoretical understanding. As James said, though, be careful you don't simply copy-paste other people's code as every university worth its salt is going to notice and call plagiarism on it.

We're not really here to do your homework for you, basically, but most of us will be more than happy to help you gain understanding of the concepts and a working implementation. :¬)
Casm
Member
Member
Posts: 221
Joined: Sun Oct 17, 2010 2:21 pm
Location: United Kingdom

Re: How to create a basic operating system?

Post by Casm »

It sounds as if the calculator might be your kernel. You don't say how sophisticated the calculator will need to be, but it will probably be enough if you can grab input from the keyboard and write output to the screen. If you stay in real mode you could use the BIOS services for that.

Your main challenge would be to write some assembly language routines to replace standard C functions like getch(), or putc(), which won't be available unless you write them yourself.

The other thing you would need to do is write a boot sector which can san through a FAT16 directory, find you calculator program, and load it. Of course, unlike a normal calculator program, this one won't terminate until your turn off the computer. It will just go round an infinite loop, getting input, doing a calculation, displaying the output, and then waiting for some more input.

If you have only got 28 days to do it, I doubt if your instructor is looking for anything much more sophisticated than that.
rsmahanti
Posts: 5
Joined: Thu Oct 07, 2010 9:59 pm

Re: How to create a basic operating system?

Post by rsmahanti »

Thanks everybody for help. I will create the os in next ten 10 days and submit the code here. except bootloader, I am not going to use single piece of code written by someone else. Thanks again for everything.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How to create a basic operating system?

Post by JamesM »

rsmahanti wrote:Thanks everybody for help. I will create the os in next ten 10 days and submit the code here. except bootloader, I am not going to use single piece of code written by someone else. Thanks again for everything.
Why submit the code here?
Joshua50187
Posts: 8
Joined: Thu Oct 21, 2010 6:29 pm

Re: How to create a basic operating system?

Post by Joshua50187 »

I would recommend sams teach yourself c++ in ten minutes (i believe that is the title) for the calculator and if its just a bet/never will ever be published under your name anywhere as your original work. then do some basic dev tutorials that give boot sector/kernel and then have it load up the program

Its not that easy and im not a expert on Os dev yet so if your just looking for a crap haha look what i can do moment then thats what i would recommend but you will feel more accomplished if you learn how to do it and then do your own code
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: How to create a basic operating system?

Post by gravaera »

I would never recommend any book on C++ whose title followed the form: "Teach yourself C++ in X days". Talk less of one that advertises the same, but in minutes...
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: How to create a basic operating system?

Post by JamesM »

gravaera wrote:I would never recommend any book on C++ whose title followed the form: "Teach yourself C++ in X days". Talk less of one that advertises the same, but in minutes...
Actually, C++ in 21 days by Sams is excellent. It's the book from which I learned.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: How to create a basic operating system?

Post by gravaera »

^ I guess that thing I said above would be just me then? Old fashioned me with my Stroustrup, and large books with lots of small text :)
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Post Reply