Simple OS - Building from linux or scratch?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Simple OS - Building from linux or scratch?

Post by Merdini »

I've been creating websites for a while now with both php and asp, but I want to digg more deeper.
I once created my own webserver and used visual basic as the serverside language.
I have created a Web based OS with javascript, opening folders, files, moving files at the "desktop" of the site, creating apps and games for the site with javascript.

My idea is to create my own simple OS, make it read the networkcard so i can get internet connection and create a webserver within the OS.

Do i need to use linux as backbone?

Waiting for answers so I can purchase some assembly books. Ether the ones involving linux, or just building the OS from scratch.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Simple OS - Building from linux or scratch?

Post by neon »

Kurdistan wrote:Do i need to use linux as backbone?
No... Not if you start from scratch. You only need to use Linux if you decide to build a distribution of it instead. If you start from scratch, you dont need to use anything at all if you dont want to.

Also, welcome to the site :)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: Simple OS - Building from linux or scratch?

Post by Merdini »

Thanks =)

I've actually been a member for 2 years, but never been active, so this is my first post =)


I will be aiming at performance first of all, so should I use Assembly or C?
Like I said in my first post, the only app that will be running on my OS is a custom webserver, indexing compressed files, decompressing, searching..... Which language should i choose?
manonthemoon
Member
Member
Posts: 65
Joined: Sat Jul 04, 2009 9:39 pm

Re: Simple OS - Building from linux or scratch?

Post by manonthemoon »

Kurdistan wrote: I will be aiming at performance first of all, so should I use Assembly or C?
This is a matter of personal preference. There are people here who only use assembly code. Also, when making an OS, a certain amount of assembly code is unavoidable. However, C shouldn't hurt performance very much (compilers are good at optimizing), and if it does you can always use a mixture of assembly and C. Only the most critical parts of your code will noticeably affect performance, so you can use whatever language you're comfortable with, and then use assembly for the important parts (if necessary).
Which language should i choose?
See Languages.


EDIT: The design of your OS will affect the performance a lot more than the language you choose, so don't be afraid to use C if that's what you want.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Simple OS - Building from linux or scratch?

Post by Kevin »

manonthemoon wrote:However, C shouldn't hurt performance very much (compilers are good at optimizing)
I dare say that compilers are optimizing better than most programmers do manually, even more if they are beginners. So you would likely gain performance from using C.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
ehenkes
Member
Member
Posts: 124
Joined: Mon Mar 23, 2009 3:15 am
Location: Germany
Contact:

Re: Simple OS - Building from linux or scratch?

Post by ehenkes »

You can use assembler for the boot process and C (it's easier than asm) for the kernel. GRUB makes life comfortable, otherwise you have to work on bootloader, or you use this: http://www.brokenthorn.com/Resources/OSDevIndex.html
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Simple OS - Building from linux or scratch?

Post by Dex »

The language is up to you, the one which you feel most comfortable with and know best is the one to use.
I use ASM only and my os can do what you want, but so can many C code ones, i do not use asm because it makes things faster, but because i like coding in its, its as simple as that.
My OS as a server.
http://www.youtube.com/watch?v=ErPDIG8HQno
dude101
Member
Member
Posts: 56
Joined: Thu Apr 09, 2009 10:26 pm

Re: Simple OS - Building from linux or scratch?

Post by dude101 »

Kevin wrote:
manonthemoon wrote:However, C shouldn't hurt performance very much (compilers are good at optimizing)
I dare say that compilers are optimizing better than most programmers do manually, even more if they are beginners. So you would likely gain performance from using C.

I agree, most modern compilers can write better code than humans. Modern CPU's are very complex.
Kitsune
Posts: 20
Joined: Wed Aug 05, 2009 7:13 pm

Re: Simple OS - Building from linux or scratch?

Post by Kitsune »

dude101 wrote:
Kevin wrote:
manonthemoon wrote:However, C shouldn't hurt performance very much (compilers are good at optimizing)
I dare say that compilers are optimizing better than most programmers do manually, even more if they are beginners. So you would likely gain performance from using C.

I agree, most modern compilers can write better code than humans. Modern CPU's are very complex.
Although, you will still need to use some asm at times, but that should mostly only be for the lowest of the low level stuff (and generally inline asm will suffice).

On the other hand, having at least a decent understanding of asm is often helpful when debugging (especially with that lowest of the low stuff I mentioned above :P )
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Simple OS - Building from linux or scratch?

Post by Dex »

dude101 wrote:
Kevin wrote:
manonthemoon wrote:However, C shouldn't hurt performance very much (compilers are good at optimizing)
I dare say that compilers are optimizing better than most programmers do manually, even more if they are beginners. So you would likely gain performance from using C.

I agree, most modern compilers can write better code than humans. Modern CPU's are very complex.
Wrong, if you take a good asm programmer and give him the task of "write better code" than a modern compilers, the asm coder will win.
But and this is a big but, most asm programmers do not try and do this, most just want to writter small code that works as it should.
But please do not think, this is because they can not, more we are lazy like the rest of you.
Merdini
Member
Member
Posts: 34
Joined: Fri May 04, 2007 10:11 pm
Location: Sweden, Gothenburg

Re: Simple OS - Building from linux or scratch?

Post by Merdini »

Thanks for all the great replies.

Dex, can your webserver only handle htmlpages?
I was thinking to make mine read ether BASIC code since i think vbscript is the fastest way to code a site, or read C++.

When it comes to the programming language of the OS, I'll use both Assembly and C.
Maybe use C++ for the webserver.
User avatar
AndrewAPrice
Member
Member
Posts: 2303
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Simple OS - Building from linux or scratch?

Post by AndrewAPrice »

Dex wrote:Wrong, if you take a good asm programmer and give him the task of "write better code" than a modern compilers, the asm coder will win.
But and this is a big but, most asm programmers do not try and do this, most just want to writter small code that works as it should.
But please do not think, this is because they can not, more we are lazy like the rest of you.
I'm in between the two. Some of the 'big' commercial compilers (VS, Intel) could take a horrendelously complex math algorithm that is spread across multiple functions, rearrange it (which it knows how to do so if you're using math.h intrinsically) so the constants are grouped, then optimise it away to one very short formula, and then there are more simpler optimisations like unrolling loops. These things could be very tedious and difficult to near-impossible to maintain (imagine changing a constant, and then rewriting a rearranged optimized math algorithm and inlining it into every place you use it). On the other hand, an assembler programmer would know constraints on certain variables (tricks that could be a lot faster than a C-style switch, as well as removing fall back cases and bound checks).

I personally don't think saving a few instructions by using a hand coded assembly function over an optimized C function is that much of a benefit, since most optimizations are done at a much higher level than the compiler can understand. So to me, I have more benefit to see my code abstracted away behind high-level classes so it is much simpler to understand the bigger picture, then reap the rewards of optimizing at that level.

But back on to the other topic, if you want to write on OS from scratch but want a solid fast foundation, you could look into using a microkernel and building your own services on top of that.
My OS is Perception.
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: Simple OS - Building from linux or scratch?

Post by Dex »

Kurdistan wrote: Dex, can your webserver only handle htmlpages?
I was thinking to make mine read ether BASIC code since i think vbscript is the fastest way to code a site, or read C++.
The simple answer is yes and no, it as a full tcp/ip stack, so its just a case of writing the basic function to implement anyother task you want it to do, but as far as that demo goes it just htmlpages, files or images etc.
Post Reply