|
1 | 1 | # cpp_concurrency |
2 | 2 | Code for the Modern C++ Concurrency in Depth course from Udemy. |
| 3 | + |
| 4 | +## Concepts |
| 5 | + |
| 6 | +Process: Is defined by its instructions and current state. |
| 7 | + |
| 8 | +Context Switching: |
| 9 | +- The OS can store the state of a process or thread, so that it can be restored and resume execution at a later point. |
| 10 | +- This allows multiple processes to share a single central processing unit (CPU), and is an essential feature of a multitasking operating system. |
| 11 | + |
| 12 | +Round-Robin Scheduling: |
| 13 | +- Assigns time-slots to each process in equal portions and circular order, having no priorities. |
| 14 | +- Context switching is performed when a time slot is completed. |
| 15 | +- Simple and starvation-free. |
| 16 | +- See: https://en.wikipedia.org/wiki/Round-robin_scheduling |
| 17 | + |
| 18 | +Task- and Data- Level Parallelism: |
| 19 | +- Task-Level: Threads perform different tasks (using the same or different data). |
| 20 | +- Data-Level: Threads perform the same task on different data. |
| 21 | + |
| 22 | +Parallelism vs Concurrency: |
| 23 | +- Parallelism: When each process/thread runs on a dedicated processor at the same time. |
| 24 | +- Concurrency: Emulated parallelism based on context-switching (sequencial execution!). |
| 25 | +- True parallelism is difficult to achieve, due to the low number of cores usually available. |
| 26 | + |
| 27 | +Heterogeneous Computing: |
| 28 | +- Refers to systems that use more than one kind of processor or cores. |
| 29 | +- These systems gain performance or energy efficiency by using specialized hardware. |
| 30 | +- https://en.wikipedia.org/wiki/Heterogeneous_computing |
| 31 | + |
| 32 | +GPGPU (General Purpose GPU): |
| 33 | +- Is the use of a GPU to handle tasks a CPU would do. |
| 34 | +- The idea is to handle matrix-like data using the GPU. |
| 35 | +- See: https://en.wikipedia.org/wiki/General-purpose_computing_on_graphics_processing_units |
| 36 | + |
| 37 | +## Building the code |
| 38 | + |
| 39 | +```bash |
| 40 | +sudo apt install gcc-10 g++-10 # C++20 |
| 41 | + |
| 42 | +mkdir -p build && cd build |
| 43 | +cmake -D CMAKE_C_COMPILER=gcc-10 -D CMAKE_CXX_COMPILER=g++-10 .. && make |
| 44 | + |
| 45 | +-std=c++20 -fcoroutines -pthread |
| 46 | +``` |
0 commit comments