Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Low level systems programming with C++

I have been using C++ for a while now and I began to get interested in lower level system programming like drivers and stuff. Even some kind of primitive operating system could be very interesting project!

I have no clue where I could start. Are there any not-too-challenging things I could get started with and are there anything about C++ I should try to avoid like exceptions in performance critical code?

My current OS is Windows 7 if that matters much.

like image 852
Henry H Avatar asked Nov 22 '10 22:11

Henry H


People also ask

Does C support low level programming?

C and C++ are now considered low-level languages because they have no automatic memory management. Olivier: The definition of low level has changed quite a bit since the inception of computer science.

What is low-level language in C?

A low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture—commands or functions in the language map that are structurally similar to processor's instructions. Generally, this refers to either machine code or assembly language.

Is C programming language high level or low level?

Examples of high level languages are C, C++, Java, Python, etc. 1. It is programmer friendly language. It is a machine friendly language.


3 Answers

Writing Windows device drivers in C++ isn't impossible, there are not many CRT functions that you could use to get you into trouble. The new operator is unusable for example, you don't have to fear a std::bad_alloc. Unless you replace it, that cuts out a rather large swath of standard C++ library classes.

But that's not really the point of a device driver, it is rather important that you make it as small as possible. C++ pays off when you write complex code. You explicitly do not want to write complex code in a device driver. Debugging it is redrum.

Linus really likes C in the kernel. There's a good reason for that.

like image 105
Hans Passant Avatar answered Oct 27 '22 08:10

Hans Passant


C++ doesn't provide quite all of the tools you will need to actually implement a full operating system in it. There are a few machine specific things that cannot be done in c++. These things are handling and raising interrupts, controlling the MMU, controlling access to supervisor cpu instructions, and a handful of other small odds and ends.

Fortunately, these things are few enough that they can be written in assembly language accessed from C++.

like image 23
SingleNegationElimination Avatar answered Oct 27 '22 07:10

SingleNegationElimination


Have a look at osdev.org (lots of questions that will pop into your mind when considering developing your own OS are answered here).

like image 1
ChristopheD Avatar answered Oct 27 '22 09:10

ChristopheD