System Programming
A few illustrated reminds about linux system programming.
For complete explanations, please have a look at : https://www.enib.fr/~harrouet
Every following examples can be downloaded here :
CODE
just write ‘make’ in a terminal to compile all of them.
Hello World
Repeat
Calculate Average
Using Files ( Low Level)
Using Files ( High Level)
Exec Function
Redirections
Process and Fork
A process is a running program.
If you want to launch another process ( child ) in a running process ( parent ),
you have to use the FORK() function.
Both of them share the same code, but the memory allowed is different.
You can distinguish them with their PID ( Process ID ).
Process Dialog : Pipes
Since processes don’t share the same memory, you can use pipes to exchange datas.
Process Dialog : Socket
Sockets can be used as pipes as well.
Process Dialog : Tubes and Redirection
Threads
Threads can be seen as ‘light’ processes.
Threads created in a process share the same memory.
Calc with threads