|
| 1 | +# Linux-System-Programming |
| 2 | + |
| 3 | +System programming starts and ends with system calls. System calls (often shortened to syscalls) are function invocations made from |
| 4 | +user space—your text editor, favorite game, and so on—into the kernel (the core internals of the system) in order to request |
| 5 | +some service or resource from the operating system. System calls range from the familiar, such as read() and write(), to the exotic, such as get_thread_area() and set_tid_address(). |
| 6 | + |
| 7 | +### How to Invoking system calls ? |
| 8 | +It is not possible to directly link user-space applications with kernel space. For reasons of security and reliability, user-space applications must not be allowed to directly |
| 9 | +execute kernel code or manipulate kernel data. Instead, the kernel must provide a mechanism by which a user-space application can "signal" the kernel that it wishes to invoke a system call. |
| 10 | +The application tells the kernel which system call to execute and with what parameters via machine registers. |
| 11 | + |
| 12 | +### what are the Libraries required ? |
| 13 | +The C library (libc) is at the heart of Unix applications. Even when you’re programming in another language, the C library is most likely in play, wrapped by the higher-level libraries, |
| 14 | +providing core services, and facilitating system call invocation. On modern Linux systems, the C library is provided by GNU libc, abbreviated glibc, and pronounced gee-lib-see or, less commonly, glib-see. |
| 15 | +The GNU C library provides more than its name suggests. In addition to implementing the standard C library, glibc provides wrappers for system calls, threading support, and basic application facilities. |
| 16 | + |
| 17 | +To date, C++ has taken a backseat to C in system programming. Historically, Linux developers favored C over C++: core libraries, daemons, utilities, and of course the Linux kernel are all written in C. |
| 18 | +Where the ascendancy of C++ as a "better C" is all but universal in most non-Linux environments, in Linux C++ plays second fiddle to C. |
| 19 | +Nonetheless, you can replace "C" with "C++" without issue. Indeed, C++ is an excellent alternative to C, suitable for any system programming task: C++ code can link to C code, invoke Linux system calls, and utilize glibc. |
0 commit comments