OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Oct 24, 2017 3:23 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: How do I get started with OS development?
PostPosted: Sun Feb 19, 2017 7:28 am 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 805
You could simplify things a bit and still learn a great deal of things if you just write your own shell (in assembly or C) to work in Linux or Windows. It will be easy to debug. When your kernel has the functionality needed for your shell, it'll be easier to port it, knowing that most of the shell already works and you just need to change 3 major things for interacting with the OS and hardware: I/O (console and file), memory management, launching a program.

You can also develop most of your GUI the same way (you can use SDL if you don't want to deal with X or Win32 API).

And the file system drivers (have a large file in Linux/Windows represent a disk).

It's not fun having to develop or debug for/under an OS that's rather incomplete or unstable (reboots, no crash dumps, no debug support).


Top
 Profile  
 
 Post subject: Re: How do I get started with OS development?
PostPosted: Sun Feb 19, 2017 1:49 pm 
Offline
Member
Member
User avatar

Joined: Wed Jun 17, 2015 9:40 am
Posts: 426
Location: Athens, Greece
Hi,


alexfru wrote:
You could simplify things a bit and still learn a great deal of things if you just write your own shell (in assembly or C) to work in Linux or Windows. It will be easy to debug. When your kernel has the functionality needed for your shell, it'll be easier to port it, knowing that most of the shell already works and you just need to change 3 major things for interacting with the OS and hardware: I/O (console and file), memory management, launching a program.
This can work assuming that you want your OS to have at least some compatibility with Linux or Windows, or that you write a wrapper that is being called using your API but ends up using the underlaying OS API.

alexfru wrote:
It's not fun having to develop or debug for/under an OS that's rather incomplete or unstable (reboots, no crash dumps, no debug support).
This is actually debatable. While I don't myself see much fun running code without debugging facilities, I'm sure there are people that actually see fun in doing that.


Regards,
glauxosdever

_________________
Before implementing any piece of software, make sure you have designed it to be extendable. Backporting new features into old code is not always easy.


Top
 Profile  
 
 Post subject: Re: How do I get started with OS development?
PostPosted: Sun Feb 19, 2017 3:08 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 805
glauxosdever wrote:
alexfru wrote:
You could simplify things a bit and still learn a great deal of things if you just write your own shell (in assembly or C) to work in Linux or Windows. It will be easy to debug. When your kernel has the functionality needed for your shell, it'll be easier to port it, knowing that most of the shell already works and you just need to change 3 major things for interacting with the OS and hardware: I/O (console and file), memory management, launching a program.
This can work assuming that you want your OS to have at least some compatibility with Linux or Windows, or that you write a wrapper that is being called using your API but ends up using the underlaying OS API.

Do you mean file names/paths? In particular, back and forward slashes? Is this something hard to redo if the author doesn't want them or wants something else in their place?

glauxosdever wrote:
alexfru wrote:
It's not fun having to develop or debug for/under an OS that's rather incomplete or unstable (reboots, no crash dumps, no debug support).
This is actually debatable. While I don't myself see much fun running code without debugging facilities, I'm sure there are people that actually see fun in doing that.

Certainly. But it would be either people who have enough knowledge/experience or people who are willing to explore/learn and not ask for help every time when faced with a problem they can't debug or don't want to get their hands and minds dirty in zeroes and ones.


Top
 Profile  
 
 Post subject: Re: How do I get started with OS development?
PostPosted: Mon Feb 20, 2017 8:18 am 
Offline
Member
Member
User avatar

Joined: Wed Jun 17, 2015 9:40 am
Posts: 426
Location: Athens, Greece
Hi,


alexfru wrote:
glauxosdever wrote:
alexfru wrote:
You could simplify things a bit and still learn a great deal of things if you just write your own shell (in assembly or C) to work in Linux or Windows. It will be easy to debug. When your kernel has the functionality needed for your shell, it'll be easier to port it, knowing that most of the shell already works and you just need to change 3 major things for interacting with the OS and hardware: I/O (console and file), memory management, launching a program.
This can work assuming that you want your OS to have at least some compatibility with Linux or Windows, or that you write a wrapper that is being called using your API but ends up using the underlaying OS API.

Do you mean file names/paths? In particular, back and forward slashes? Is this something hard to redo if the author doesn't want them or wants something else in their place?
I think there was a misunderstanding here. File names/paths are only a small subset of what I am talking about. Mostly, I meant functions, libraries and programs (let's call them "interfaces") that may not be present either on the OS on the development machine or on your future/final OS.

If you are doing a POSIX-compliant or Windows-compatible OS, what I stated is not a concern, since both the OS on the development machine and your future/final OS will end up having the same "interfaces".

If you are doing an OS that won't be compatible with any other OS (not only binary-code-wise, but also source-code-wise), you can't really write a shell using the "interfaces" of the OS on the development machine and expect it to work on you future/final OS without some kind of compatibility layer (the "wrapper" I said earlier - bad terminology from my part).

A relevant topic might be this one. Essentially, someone wants to write some "interfaces" of his future/final OS in a way to work on the OS of the development machine.


Regards,
glauxosdever

_________________
Before implementing any piece of software, make sure you have designed it to be extendable. Backporting new features into old code is not always easy.


Top
 Profile  
 
 Post subject: Re: How do I get started with OS development?
PostPosted: Mon Feb 20, 2017 8:19 pm 
Offline
Member
Member

Joined: Tue Mar 04, 2014 5:27 am
Posts: 805
glauxosdever wrote:
If you are doing an OS that won't be compatible with any other OS (not only binary-code-wise, but also source-code-wise), you can't really write a shell using the "interfaces" of the OS on the development machine and expect it to work on you future/final OS without some kind of compatibility layer (the "wrapper" I said earlier - bad terminology from my part).


For a basic shell you don't need a lot of OS-specific functionality and writing wrappers for what's needed should not be a big deal.


Top
 Profile  
 
 Post subject: Re: How do I get started with OS development?
PostPosted: Mon Feb 27, 2017 1:29 am 
Offline

Joined: Sun Feb 26, 2017 4:42 pm
Posts: 16
My second stage boot loader, kernel and drivers are written in C++ & assembly. I don't use inline assembly because then I can't port it to other architectures.

I wrote a 16-bit boot loader entirely in assembler in my teens (many years ago) and I built on top of that to first build a 32-bit x86 operating system and then a 64-bit x86-64 bit operating system. At this point I have been programming in assembly language for >20 years. I've written shipping product level OS assembly code (for the Microsoft Windows kernel) in x86, x64, IA64 and ARM assembly language.

Yet I would never write a kernel entirely in assembly language. It's not necessary and it would be extremely time consuming and trust me I'm a very proficient assembly language programmer. In addition I would also be tied only to the architecture of the specific instruction set. I re-used a lot of my 32-bit OS in the 64-bit one because all I had to do was recompile the C++ code for x86-64 and write the low-level architecture specific code in assembly using the correct calling convention for C/C++ so that it could be invoked from there.

My interrupt service routines are also C++ with only a very small portion being written in assembly and all that does is gather the necessary information for the interrupt setup a valid stack frame and jump into the C/C++ interrupt handler.

I have assembly routines that are called from C/C++ for things like read from IO ports etc.

This is nothing new, Windows and Linux follow similar models - write anything machine specific in assembly language and write everything else in a language that can be ported to other architectures.

While assembly language can be a lot of fun to play with, always use the best tool for the job. Assembly for machine specific stuff, some other language for that which could be used on a different architecture.

In terms of actually getting started on OS development figure out:
1. What do you hope to achieve with your OS? Is it just a learning experience or do you want to make it useful to yourself and others?
2. Is there some problem you're trying to solve that other OSes haven't addressed?
3. Will it it be a standard desktop type operating system or did you want make it distributed like Andy Tanenbaums Amoeba operating system? Or do you plan to make it an embedded system?

Now for actually getting started, I would suggest reading books on operating systems. Andy Tanenbaums are good. There are also others by Silvershatz and Deitel. I'm sure there are more, I only know of the latter two because I was one of the reviewers and wrote some portions of a chapters specific to the Windows Kernel.

The books will give you more insight into what an operating system does, how things are structured etc. it's all well and good to look at examples of code on the internet but that will never tell you why something is done in a specific way or what alternatives exist etc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], klange and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group