Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » How do you create an OS and programming language?
Closed Thread
Old 02-03-2006, 07:07 PM   #1 (permalink)
 
Newb Techie

Join Date: Jan 2006

Posts: 39

smartydebater

Default How do you create an OS and programming language?

I know that creating an OS and my own programming language would be a big feat. But could anyone at least start explaining to me how I could do it? Or where I can find information on it?

Thanks!!!
smartydebater is offline  
Old 02-03-2006, 07:23 PM   #2 (permalink)
Chankama's Avatar
 
Monster Techie

Join Date: Jan 2005

Location: Canada

Posts: 1,522

Chankama will become famous soon enough

Default

Well, for operating systems, I think reading up on Real Time Operating Systems is probably a good starting point. I think any search for "Operating Systems" on google will give you junk. RTOS will probably give you more pertitent information.

First you need to understand the underlying instruction set of the processing unit. Then you need to start modelling your OS, as well as decide whether this will be a multitasking or non-multitasking OS.

You need to read up on things like schedulers, preemption, blocking, interrupt routines, etc.

For a compilers, are you thinking of an intepreted language or a compiled language?

Either way, you need to build a good language parser.
Chankama is offline  
Old 02-03-2006, 08:35 PM   #3 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

To really write an OS you are going to need to know your processors assembly inside and out.

You're also going to have to be very very good at C.

The true beginning of an OS is basically building a binary image that you can write to a floppy disk (or other bootable media). This binary image basically contains a few lines of assembly that direct the computer to begin loading the rest of the OS (specifically the interrupt handler) from the floppy disk or the hard drive.

Once the interrupt handler is in place in memory, the fence register in the CPU must be set so that user programs cannot overwrite the interrupt handler.

Next, the System Vector Call table (syscall) must be loaded. This would be generally your lowest level functions like console input and output. This would also be basic functions that handle basic disk access. These syscalls are generally written in C with built-in assembly routines. In these cases, the C files must not rely on any standard libraries. All syscalls can only consist of the most basic C language statements, no libraries.

The next step is to pass control over the machine over to whatever higher level layer exists. In most cases, there are many layers between the SVC table, interrupt handler, and the end shell/interface.

If you were writing an OS at this point, you would want to implement your own implementation of the C standard libraries (or download a working source) and get those running on your system.

At this point, you are ready to execute binaries compiled using a high-level language like C and the standard libraries. Generally you only want the OS kernel to run at this level. The kernel then, combined with the interrupt handler, sets up a multi-programming environment. This just means you enable the 'OS' to manage processes and threads, and if neccesary handle multiple processes and context switching.

Once you are this far you would also want to write drivers to wrap the assembly calls (or low level syscalls) that are required to interface with the rest of the system hardware. This includes, but is in no way limited to sound cards, high-resolution video adapters, mouse or keyboard input, and any other essential hardware.

Finally, once this is completely done, you could write a shell or some other interface. This could be as simple as a command line, or you could use your driver layer to render high resolution graphical video. Either way, you are writing the main process by which the user interacts with the OS, including input/output, and launching and managing other processes.

At this level, you've basically got a complete OS. Theoretically you could compile and run user programs at this point.

Of course, what I've described easily encompasses months if not years of work. An OS that implements what I've described could easily be thousands and thousands of lines of code.
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On