LBE-OS is a repo full of code snippets to help you complete your OS labs.
A few things to point out :
- Though I did my best, I might have done some mistakes along the way, let me know AND/OR contribute to fix them!
- Think there would be more interesting things to add in there, feel free to add them OR request that I do a quick example.
- Without sharing, we won't go anywhere! Contribute! Go Open! Drink tea.
To run any code example in a Linux environment (I use ubuntu) do the following :
1) Compile any .cpp file :
gcc 01fork.cpp -o output
For the Thread section you need to add the
2) Execute the corresponding output file :
- 01fork.cpp - Creating a new process
- 02waitpid-basic.cpp - Wait for a given process to terminate
- 02waitpif-elaborated.cpp - Wait for a given process to terminate and retrieve signal or exit value
- 03waitpid-nonBlocking.cpp - Wait for a given process to terminate without blocking the parent process
- 04wait.cpp - Wait for all process to terminate
- 01execve.cpp - Replacing the child process image by a new one
- 02execlp.cpp - Replacing the child process image by a new one
- 03execvp.cpp - Replacing the child process image by a new one
- 04exec-example.cpp - Replacing the child process image by a new one using a user created executable
- 05execWait-example.cpp - Replacing the child process image by a new one and wait for the child process to terminate before terminating the parent process
- 01pipe.cpp - Communication using a pipe and file descriptors (parent process writing to child process)
- 02pipe-interProc-basic.cpp - Communication between 2 process using a pipe and file descriptors
- 02pipe-interProc-elaborated.cpp - Communication between 2 process (using a user created executable and passing fd as arguments)
- 03pipe-twoWayComm.cpp - Communication using a pipe and file descriptors (two way communication)
- 01thread.cpp - Launching threads for specific task
- 02thread-arguments.cpp - Passing arguments to threads
- 03thread-multipleTask.cpp - Clean way of launching multiple threads
- 01mutex.cpp - Basic synchonization using mutex (binary semaphores)
- 02semaphore-prodCons.cpp - Synchronization using semaphore. An example of the producer - consumer problem
FIFO coming soon.