From 6dbac7559a0ec56a7e46a1cda7ec1b5680204b07 Mon Sep 17 00:00:00 2001 From: Shaun Reed Date: Wed, 4 May 2022 12:54:06 -0400 Subject: [PATCH] [cpp] Update READMEs for C++ projects and examples --- cpp/README.md | 13 +++++++------ cpp/multithreading/CMakeLists.txt | 3 +++ cpp/multithreading/README.md | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 cpp/multithreading/README.md diff --git a/cpp/README.md b/cpp/README.md index 12c17f7..87f20b8 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -2,12 +2,13 @@ ```bash shaunrd0/klips/cpp/ -├── algorithms # Examples of various algorithms written in C++ -├── cmake # Example of using cmake to build and organize larger projects -├── cryptography # Examples of encrypting / decrypting using ciphers in C++ -├── datastructs # Collection of useful datastructures written in C++ -├── graphics # Examples of graphics projects written in C++ -├── patterns # Examples of various design patterns written in C++ +├── algorithms # Examples of various algorithms written in C++ +├── cmake # Example of using cmake to build and organize larger projects +├── cryptography # Examples of encrypting / decrypting using ciphers in C++ +├── datastructs # Collection of useful datastructures written in C++ +├── graphics # Examples of graphics projects written in C++ +├── multithreading # Basic multithreading examples in C++ +├── patterns # Examples of various design patterns written in C++ └── README.md ``` diff --git a/cpp/multithreading/CMakeLists.txt b/cpp/multithreading/CMakeLists.txt index f04f838..439024c 100644 --- a/cpp/multithreading/CMakeLists.txt +++ b/cpp/multithreading/CMakeLists.txt @@ -15,6 +15,9 @@ project( LANGUAGES CXX ) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +add_compile_options("-Wall") + add_subdirectory(conditions) add_subdirectory(deadlock) add_subdirectory(livelock) diff --git a/cpp/multithreading/README.md b/cpp/multithreading/README.md new file mode 100644 index 0000000..e8f8059 --- /dev/null +++ b/cpp/multithreading/README.md @@ -0,0 +1,25 @@ +# Multithreading + +A few basic multithreading programs written in C++ while learning about +the [concurrency support library](https://en.cppreference.com/w/cpp/thread) + +``` +klips/cpp/multithreading +. +├── conditions # Using condition_variable to control job execution flow +├── deadlock # Example of problem and solution for deadlocks +├── livelock # Example of problem and solution for livelocks +├── race-condition # Example of problem and solution for race conditions +└── README.md +``` + +We can build the examples with the following commands. + +```bash +cd /path/to/klips/cpp/multithreading/ +mkdir build && cd build +cmake .. && cmake --build . +ls bin/ + +multithread-conditions multithread-deadlock multithread-livelock multithread-race-condition +```