FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Custom Operating System in C#, C++, or Java





TheRPGLPer
I'm thinking about making a custom operating system built on either C#, C++, or Java, which ever one works the best, and I was going to ask, which scripting language would be the easiest?
Peterssidan
An operating system is like a layer between the hardware and the programs. To be able to communicate with the hardware you probably need to use something as low level as assembly.

If you are going to use compiled high level languages like C, C++ you need to be able to compile the code to run on your OS. You might be able to port some open source compiler to be able to produce binary code that runs on your OS.

Java and C# is a bit more high level and lack some of the low level features of C and C++ so I think C or C++ is a better choice, at least for the core of your OS. I have no idea how much work it is to make Java and C# to run on a new OS.

You should also consider being compatible with other OS:s to make it easier to borrow things from other OS:s. Linux for instance is pretty much unix/posix compatible.
TheRPGLPer
I've messed around with some form of Assembly called ASM that changes hex values in this game that adds new features, but I don't know if the actually Assembly code is as simple as that. If it is just changing hex values like Super Mario World's ASM, then I can do the operating system in Assembly and then more and likely C# or C++. It would more and likely be linux based though.

We'll see what I could do, but my currently project is a RPG for Android and Windows (not iOS or MAC because I don't have a MAC and cannot compile iOS XCODE).

My next project will be a custom operating system.
pauline123
If you have not written complex pieces of software, I would cautiously rethink planning on how you would go about writing your OS or if you should. However, that being said an OS can be extremely simple and only do a few things like boot and then shut down the computer. Personally I would focus on getting that functionality working before tackling anything larger for your OS. It does not really matter which language you write it in at some level it will be turned into binary. Also, remember that linux is actually only a kernel not an OS. If you write your kernel with interoperatibility in mind things will get easier as you go.
cybersa
Peterssidan wrote:
An operating system is like a layer between the hardware and the programs. To be able to communicate with the hardware you probably need to use something as low level as assembly.

If you are going to use compiled high level languages like C, C++ you need to be able to compile the code to run on your OS. You might be able to port some open source compiler to be able to produce binary code that runs on your OS.

Java and C# is a bit more high level and lack some of the low level features of C and C++ so I think C or C++ is a better choice, at least for the core of your OS. I have no idea how much work it is to make Java and C# to run on a new OS.

You should also consider being compatible with other OS:s to make it easier to borrow things from other OS:s. Linux for instance is pretty much unix/posix compatible.


I'm interested in this.
But don't know where to start.
Do you have any guide?
Peterssidan
TheRPGLPer wrote:
I've messed around with some form of Assembly called ASM that changes hex values in this game that adds new features, but I don't know if the actually Assembly code is as simple as that. If it is just changing hex values like Super Mario World's ASM, then I can do the operating system in Assembly and then more and likely C# or C++. It would more and likely be linux based though.

The hex values that you talk about is probably the machine code viewed in an hex editor. It's probably good enough if you want to hack a game to get a lot of lives but writing any actual functionality is quite hard that way. Assembler is written in text like other programming languages because it's much easier for humans to handle. The assembly will differ depending on the hardware you are programming for.

TheRPGLPer wrote:
It would more and likely be linux based though.

Ok, so you are not going to write everything from scratch. Good, that will make things much easier. So what exactly is it that you want to write/add? If you just want to create your own linux distribution you probably don't have to write much code at all.

pauline123 wrote:
Also, remember that linux is actually only a kernel not an OS.

There are different definitions of what an OS is. Some say the kernel is the OS. Some say it's just part of the OS. TheRPGLPer, what is it you mean by OS?

cybersa wrote:
I'm interested in this.
But don't know where to start.
Do you have any guide?

No, I don't have any guide on how to create an OS. If you are seriously interested in how they work you should probably read some books about it.
Mr_Howl
Writing code in Assembly is hard. For example, take the case of a simple For loop (Source for this example):

In C:
Code:

for (i = 0; i < 4; i++) {
// stuff
}


In MIPS assembly:
Code:

add $t0, $zero, $zero # i is initialized to 0, $t0 = 0
Loop: // stuff
addi $t0, $t0, 1 # i ++
slti $t1, $t0, 4 # $t1 = 1 if i < 4
bne $t1, $zero, Loop # go to Loop if i < 4


Note how much extra effort that is, and that's only a single for loop! Just imagine trying to deal with something like an object or a struct.

In Java, you have new. In C, you have malloc and free. In Assembly, not only do you have to handle all the memory yourself, you have to handle the actual registers on the processor.

But since you said you were interested in using Linux, you may find this very useful: Linux from Scratch. That's a guide on how to do everything yourself. Straight from the source, no distribution; hand-picking and configuring all the utilities and programs. I plan on doing this for my recently-acquired Raspberry Pi.
Peterssidan
Note that everything after # and // is comments in the MIPS assembly example above. I mention it because it's probably not obvious for someone who has never seen assembly before.
cybersa
Mr_Howl wrote:
Writing code in Assembly is hard. For example, take the case of a simple For loop (Source for this example):

In C:
Code:

for (i = 0; i < 4; i++) {
// stuff
}


In MIPS assembly:
Code:

add $t0, $zero, $zero # i is initialized to 0, $t0 = 0
Loop: // stuff
addi $t0, $t0, 1 # i ++
slti $t1, $t0, 4 # $t1 = 1 if i < 4
bne $t1, $zero, Loop # go to Loop if i < 4


Note how much extra effort that is, and that's only a single for loop! Just imagine trying to deal with something like an object or a struct.

In Java, you have new. In C, you have malloc and free. In Assembly, not only do you have to handle all the memory yourself, you have to handle the actual registers on the processor.

But since you said you were interested in using Linux, you may find this very useful: Linux from Scratch. That's a guide on how to do everything yourself. Straight from the source, no distribution; hand-picking and configuring all the utilities and programs. I plan on doing this for my recently-acquired Raspberry Pi.

Yeah its very hard.
if you learned high level language,then it very hard to learn assembly language.

Linux from Scratch that's nice.
Thanks for the link.
TheRPGLPer
The ASM used in the game is not just editing hex values, it's written like this:
http://pastebin.com/Rb85mDnN

I know enough about this form of ASM to write basic blocks and patches for the game.

The game AsSeMbly (<-- ASM styled like that) is very similar and not as easy as the actual assembly either.

Also, there is a wiki online somewhere that is a start to finish guide for an operating system.
EDIT: This is it

I'm going to start with ASM to get booting and shutting down, easier stuff like that to work first and the GUI OS will be written in C# or C++.

EDIT: For me, this task would take a while and to cybersa, the OSDev Wiki helps a lot with this task.
stblack
Hi,
you can have a look at the wikipedia page http://en.wikipedia.org/wiki/Singularity_ (operating_system) to start from what is already been designed and done, but no more mantained or developed.
There is instead http://en.wikipedia.org/wiki/Cosmos_ (operating_system) that is still active.

Stblack

(Edit by Bondings, changed the url's a bit as due to a phpbb bug they are preventing your post from being displayed.)
Bondings
TheRPGLPer wrote:
The ASM used in the game is not just editing hex values, it's written like this:
http://pastebin.com/Rb85mDnN

I know enough about this form of ASM to write basic blocks and patches for the game.

That indeed looks a lot like assembly code. If you know how to code that, I guess it won't be too hard to learn x86 assembly.
cybersa
stblack wrote:
Hi,
you can have a look at the wikipedia page http://en.wikipedia.org/wiki/Singularity_ (operating_system) to start from what is already been designed and done, but no more mantained or developed.
There is instead http://en.wikipedia.org/wiki/Cosmos_ (operating_system) that is still active.

Stblack

(Edit by Bondings, changed the url's a bit as due to a phpbb bug they are preventing your post from being displayed.)


Corrected the link:
Singularity_(operating_system):
http://en.wikipedia.org/wiki/Singularity_%28operating_system%29
Cosmos_(operating_system):
http://en.wikipedia.org/wiki/Cosmos_%28operating_system%29
Bondings
cybersa wrote:
Corrected the link:
Singularity_(operating_system):
http://en.wikipedia.org/wiki/Singularity_%28operating_system%29
Cosmos_(operating_system):
http://en.wikipedia.org/wiki/Cosmos_%28operating_system%29

Oh great! I never thought to do that and that it would work. Now at least I know how to fix the empty posts without breaking/removing the links. Now just remember %28 and %29.
MikeFromHC
TheRPGLPer wrote:
I'm thinking about making a custom operating system built on either C#, C++, or Java, which ever one works the best, and I was going to ask, which scripting language would be the easiest?


None of those languages are what would normally be called scripting languages.

Java, is the P-system of the 90's but did manage to hold on in some niche.
It has the advantage of being able to run on any platform.
It has the disadvantage of being able to run on any platform.
No one has written a cross complier that is faster than one written for a specific platform.

The idea is that once you have learned a (computer) language learning others is easy.
In general this is true as they all do the same basic functions.
I'd say C ++ is the most likely choice for what you want.

But the important question is what do you want to do?
Unix was written for a very specific purpose which ha nothing to do with business, graphics, or anything else. It was built to run switches.
Pick on the other hand was designed and build from the ground up as an OS that was also a database and designed to be used in business.

Sit down and ask yourself what you want this system to do and if it is worth reinventing the wheel to do it.
Related topics
What is your operating system?
Creating a new Operating System
FreeBSD-also a good operating system
blackhawk [microsfot new server operating system but...
Windows XP the best?
What operating system do you use?
I Need distributed Operating System
sticking "Creating a new Operating System"
how to create an operating system?
The Singularity Operating System
BlueFeather Operating System
PocketPC Operating System change
Why do you use your current operating system?
what do you recommend for intranet system using java N OODB
Reply to topic    Frihost Forum Index -> Computers -> Operating Systems

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.