Hello,

Hope this is the right place to post, I am a student and want to create an OS like DOS just for practice, I know functions, arrays, pinters, structures and file handling but dont know how to start writing an OS, please help me.

Regards.

Recommended Answers

All 14 Replies

You can download source code for os like minix and play with it.

You can download source code for os like minix and play with it.

Thanks ithelp but I want to learn creating an OS, not to copy others code.

You learn by checking out how someone else coded theirs. Find a couple more
O/S's to look at and check for similarities and differences. Linux is also available as source.

Dear you are right but if some one just give me the basic code, I mean just the start and then I can learn from those source codes as well.

>>but if some one just give me the basic code, I mean just the start
Ok -- here goes

#include <stdio.h>

int main()
{
    // put your code here
    
    return 0;
}

Before doing anything, learn to read English. That is an absolute must prerequisit. Apparently you have failed to do that because it seems you did not yet read any of the links or comments in any of the previous posts. Writing an operating system is not child's play or someting that a first or second year college IT student would be expected to tackle. Bill Gates didn't even do that -- he bought the original source code from someone at IBM.

Hope this is the right place to post

Well, maybe you actually have to turn to other forums and request for the basic OS starter code there.
By following Ancient Dragon's links above, you probably find relevant places sooner than later.

Not sure if it works but this is what I found

#include "bloader.h"

int main();

/*Global Variables BAD BAD:) */
unsigned int oldEBP;
struct boot_dir *viewableDirectory;
int totalMem;
char * passedParams;
/*end global vars */

void _start(int memSize, char *parms, struct boot_dir *loadedfiles)
{
	asm("mov %%ebp, %0":"=m"(oldEBP));
	viewableDirectory = loadedfiles; /*make file mem locations global*/
	totalMem = memSize; /*make mem of system global*/
	passedParams = parms; /*make paramaters passed to system global*/
	main();

	asm("hlt");		/* this halts the machine, solving the problem of triple-faults on 
							some machines, but also making it impossible to return to DOS */
}

int main()
{
	char *vidmem = (char *) 0xb8000;
	
	/* "Hello " */
	vidmem[0] = 'H';
	vidmem[1] = 0x7;
	vidmem[2] = 'e';
	vidmem[3] = 0x7;
	vidmem[4] = 'l';
	vidmem[5] = 0x7;
	vidmem[6] = 'l';
	vidmem[7] = 0x7;
	vidmem[8] = 'o';
	vidmem[9] = 0x7;
	vidmem[10] = ' ';
	vidmem[11] = 0x7;

	/* "World " */
	vidmem[12] = 'W';
	vidmem[13] = 0x7;
	vidmem[14] = 'o';
	vidmem[15] = 0x7;
	vidmem[16] = 'r';
	vidmem[17] = 0x7;
	vidmem[18] = 'l';
	vidmem[19] = 0x7;
	vidmem[20] = 'd';
	vidmem[21] = 0x7;
	vidmem[22] = ' ';
	vidmem[23] = 0x7;

	/* "OS" */
	vidmem[24] = 'O';
	vidmem[25] = 0x7;
	vidmem[26] = 'S';
	vidmem[27] = 0x7;

	return 0;
}

AT this link http://www.acm.uiuc.edu/sigops/roll_your_own/

Member Avatar for iret

The best way to learn is to study free sources. Learn how their code works, then make it your own by adapting it to your needs/philosophy.

Ok -- here goes
C Syntax (Toggle Plain Text)
#include <stdio.h>

int main()
{
// put your code here

return 0;
}

Before doing anything, learn to read English. That is an absolute must prerequisit. Apparently you have failed to do that because it seems you did not yet read any of the links or comments in any of the previous posts. Writing an operating system is not child's play or someting that a first or second year college IT student would be expected to tackle. Bill Gates didn't even do that -- he bought the original source code from someone at IBM.

I don't think so. When making operating system you don't #include <stdio.h>, and the first function is not main (but if you want to name it that it will work) but is determined by boot assembly file, which you have to make yourself too, and Kernel doesn't always return a variable.

For anyone wanting to write his/her own os, you really need to go here.

What I would do is right a bootloader(proably in C++) and then get linux at https://www.kernel.org/ and have that run on top of it and then finally write some programs and put them in a startup directory that the kernal runs everything thats inside on bootup

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.