Page 1 of 1

OPerating System Design using C

Posted: Mon Sep 02, 2002 9:12 pm
by Sundeep
How to start designing my own operating system using the C Language.Please help

Re:OPerating System Design using C

Posted: Tue Sep 03, 2002 1:06 am
by frank
first get your C kernel loaded...
using assembly - mbr (like me) or a bootloader (grub)
you can also try to write a bootblock (which reads the partition table and starts your kernel) and let lilo (or another bootblockloader (:)) start it...

Then start writing your kernel...

Code: Select all

asm("jmp main");

int main()
{
 while (1)
  {

  }
}

That's a basic kernel which hangs...
Then start thinking about a filesystem so you can start a user program (which allows the user to start other programs -- shell)
kernel modules etc.

Re:OPerating System Design using C

Posted: Tue Sep 03, 2002 1:10 am
by Pype.Clicker
First try to figure out what services are needed. OS design starts with a pen and a lot of paper, not with a programming language.
  • Are you going to support multiprogramming, if you do, how will context switching be handled ? what will be the architecture of your scheduler ? what kind of parameters will it need ? how will it be called ?
  • Are you going to provide pluggable modules ? if yes what kind of info do they need ? and how will The System remember infos about them ?
  • Are you going to provide virtual memory ? ...
There are as much possible starts as there are possible codes. Do NOT just start with a bootsector because XYZos did : if what interrest you is memory allocation algorithms, ask Linux (or dos if you plan a 16 bits OS rather than a 32 bits one) a large bunch of memory and write your allocation routines in that area ... If you'd like to learn how to use IDE disks and file systems, then forget about Linux (because writing a Linux module will be lightyears from new OS desing) and start with your FS stack using someone else code as a substrate (it could be Djgpp, or BIOS-based ... It could even work on a simulated ramdisk and be developped directly in a user-level and OS-independent application)

It will be more interresting for every buddy if we don't start with a buggy boot sector but have some stuffs that other needs to step forward :)

Re:OPerating System Design using C

Posted: Tue Sep 03, 2002 5:52 am
by Tom
If you want to just program the OS just in C, that's imposible, you need some assembly.

On a floppy drive, to make your OS, this needs to happen: Assembly Bootsector->Protected Mode->GDTR->C kernel made with GCC.

Making your own Assembly bootsector is REALLY hard. It took me 3 months :-[ because I had to learn alot. Making your own OS is alot different than programming with VC++ or VB.

If your wondering what Protected Mode ( PMode ) is, it's a processor ( CPU ) mode that interrupts are disabled ( well, there's alot more to PMode ).

Oh yea, there IS this link that shows you how to make a bootsector in C, using GCC, with real-mode CGG code ;D.
I haven't tested it, because I'm already past this step.

http://www.developerpit.com/compiler_options.html

Mabe with that link...you might be able to make your own bootsector in C ( I suggest not to ).

I have my own OS in C, and you can use it's code.
it's called FritzOS ( no, not chips :P, Fritz is my name ), here is the link www.sourceforge.net/projects/fritzos

I hope that helps you,

Re:OPerating System Design using C

Posted: Tue Sep 03, 2002 6:29 am
by frank
Posted on: Today at 06:52:30am If you want to just program the OS just in C, that's imposible, you need some assembly.
well, you could use 2 compielrs, 1 16bit and 1 32 bit :P
but uhm, I suggest you use assembly for your bootsector and then use gcc (like me) :)

some people told me "use grub" all the time, which really pissed me off :)
so I just started coding, didn't give up and now I have it...
(a bootsector at the mbr)
nothing is hard if you know how to do it :)

Making your own Assembly bootsector is REALLY hard. It took me 3 months because I had to learn alot. Making your own OS is alot different than programming with VC++ or VB.
it took me 2 weeks or something...

before that I didn't know about pmode and so, so I tried to implent my filesystem in the bootsector :-[
(I'm not counting that in with my programming time :P)
If your wondering what Protected Mode ( PMode ) is, it's a processor ( CPU ) mode that interrupts are disabled ( well, there's alot more to PMode ).
(32bit) pmode allows you to use max 4 gigabyte of memory.