What is system programming

Briefly, the Practice of writing system software is called system programming.
“hey tell me something I don’t know!” whispering the audience!

I’m trying to use some metaphors in order to make the concept more understandable.

Depending on what programming language you use (or need to use!) you will use the interface and the facilities that the language provides, some of them will put you on top of mountains as Lord commander and asking you only three commands (start the war, stop the war, surrender to the enemy)!

some other programming languages will ask you every details, most of the actions taking place in the game, Imagine some extreme cases your self ;)

If you are asking yourselves “why should I bother learning this kind of stuff?” I have asked the same question and I conclude In general understanding how the low-level magic happens under the hood helps me write and understand code better.

by low-level I don’t mean signals and electrons! I mean how OS will handel the steps required; we can go deep and deeper but personally I don’t need that.

System Programming Cornerstones

system programming is all about requesting resources or services from user-space to OS in order to access kernel-space ,let’s first talk about syscall’s and how we can invoke them, after that Ill explain a bit more about glibc and the wrappers it provides to make our experience much more easier, in the end we will have some glimpses of gcc.

System call (syscall)

Syscalls varies architecture to architecture but most of them are the same, nearly 10 percent of them are unique to the architecture.

Invoking a syscall is pretty straight forward, Application signals the kernel, just after that kernel provides a protected area of it self to handle he request, this mechanism is not the same in all architectures but they are obeying the same principals.

The C library

Lets focus on glibc, it brings more than what standard C library does, while we are doing high-level stuff glibc is doing all the low-level parts for us, it wraps the complicated parts and arms us by wrapping syscalls and threading support.

The C Compiler