Which Programming Language for OS

Status
Not open for further replies.
Solution
The version is probably the least important information as you want your OS to run on any version of the processor.

I mean that you have to understand the way that the processor works, the registers it contains, and all the instructions that it obeys. For example, with an x86 processor you need to understand the state it is in when it starts up and how to move it from real mode to protected mode and then (possibly) to 64-bit long mode. To do this you will need to understand how the processor uses the segment registers to address memory and how it translates virtual addressed to physical addresses via the paging mechanism. That's just for starters.

The processors are very well documented by the manufactures (the Intel Programmer's...

Ijack

Distinguished
The commonest, and easiest, language to use for these purposes is C, with a certain amount of assembler, although other languages can be used. Early OSs were written entirely in assembler and this is still the approach taken by some individuals.

Much more important than the language used is that you have a thorough understanding of the processor and support chips that you are targetting your OS at.
 

War_Mechine

Estimable
Sep 10, 2014
9
0
4,510


by saying understanding of the processor and support chips do you mean the version it's capabilities and all the details about them.
 

Ijack

Distinguished
The version is probably the least important information as you want your OS to run on any version of the processor.

I mean that you have to understand the way that the processor works, the registers it contains, and all the instructions that it obeys. For example, with an x86 processor you need to understand the state it is in when it starts up and how to move it from real mode to protected mode and then (possibly) to 64-bit long mode. To do this you will need to understand how the processor uses the segment registers to address memory and how it translates virtual addressed to physical addresses via the paging mechanism. That's just for starters.

The processors are very well documented by the manufactures (the Intel Programmer's Manual, which is a free download explaining every aspect of how the processor works, comes as a 5-volume manual), the support chips less so. And some peripherals are more difficult to control than others - text display, keyboard input, hard disk support are easy; graphic display more difficult, and USB devices difficult even for the most expert programmers.

Basically, OS programming is about the most difficult development work that you can undertake. But if you are already skilled in assembly language and a higher-level language such as C it can be a very rewarding hobby.
 
Solution

War_Mechine

Estimable
Sep 10, 2014
9
0
4,510


can you tell from where i can get the manual
 

Pinhedd

Distinguished
Moderator


As Ijack mentioned the predominant language for operating system level programming is C, although C++ may be used to a limited extent. C++ leans on the C++ standard library for language features whereas C does not. For example, dynamic memory allocation in C++ is a language feature accessible through the new and delete keywords. These are provided by the C++ standard library. Their C analogues, malloc() and free(), are function calls rather than keywords. The standard libraries for either of them are not available to the kernel, so the kernel designer is responsible for implementing the kernel's own memory manager as well as providing the mechanisms to allow applications to manage their own memory.

All operating systems will rely on the target platform's assembly language to a small degree as there's no elegant way to perform platform specific operations such as switching operating modes, managing interrupt vector tables, handling hardware exceptions, etc... C was designed with the purpose of enabling the Unix operating system to be platform portable, but a small amount of the code simply can't be ported. Windows wraps all of the platform specific stuff up in the hardware abstraction layer, hal.dll. The Windows NT kernel itself is fully portable.

There is an experimental system called Singularity which uses fully managed code including the kernel and device drivers. It is written in a language that is an extension of C# (C# itself is not suitable for system level programming). This operating system still relies on C and assembly for some of the very low level operations such as loading the kernel and handling interrupts.
 

Ijack

Distinguished

Pinhedd

Distinguished
Moderator


I hope that you mean the forums on that site, not here on Tom's Hardware.
 
Status
Not open for further replies.

TRENDING THREADS