CREATING MULTITHREADED PTOGRAMS IN C++

2023;
: 19-27
https://doi.org/10.23939/cds2023.01.019
Received: July 17, 2023
Revised: September 28, 2023
Accepted: October 10, 2023
1
Lviv Polytechnic National University
2
Lviv Polytechnic National University

For many years, the increase in computing power of modern devices is achieved not by increasing the clock frequency and bandwidth of CPUs, but by using hyper-threaded and multicore architectures. This simple change in approach to the CPU design led to dramatic changes in the organization of computing and became a turning point for software developers. Software that is going to take advantage of the increased computing power of multi-core architectures must be designed to be able to perform multiple tasks simultaneously. When covering the topic of parallel/simultaneous computing, scientists and IT professionals use two terms: (1) parallelism and (2) concurrency. A third important term when considering parallel/simultaneous computing is “multithreading”. In C++, the two most common ways to implement parallelism are concurrency and parallelism itself. Although they can be used in other programming languages, C++ stands out for its ability to use concurrent computations with lower-than-average utilization of general machine resources, as well as its ability to execute complex instructions. The C++11 standard introduced support for multi-threaded programs. The C++ standard recognized the existence of multithreading in the language and provided components for writing multithreaded programs in the library. This made it possible to write multithreaded programs in C++ without relying on platform-specific extensions and enabled the creation of portable multithreaded code with guaranteed behavior. The library provides extensive opportunities for organizing parallel and concurrent calculations, it also contains the C++ memory model, conditional variables, mutexes, etc. for thread synchronization. The article analyzes the possibilities of writing programs in the C++ using multiple threads for parallel and concurrent execution of tasks. It also considers the features of the C++ and the tools of the library that make parallelism and concurrency possible.

1. Sutter H. (2009). The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software. Retrieved from: www.gotw.ca/publications/concurrency-ddj.htm

2. Acar U. A., Chargueraud A., Rainey M. (2016). An Introduction to Parallel Computing in C++. Retrieved from: www.cs.cmu.edu/afs/cs/academic/class/15210-f18/www/pasl.html

3. Wataru E., Shigeyuki S., Kenjiro T. (2022). ComposableThreads: Rethinking User-level Threads with Composability and Parametricity in C++, Journal of Information Processing, Vol.30, 269–282. https://doi.org/10.2197/ipsjjip.30.269

4. Qiu W., Zhang Y., Wang L. (2019). Visual C + + and MFC Application in Safety Monitoring System of Airplane Depot, Advances in Computer Science Research, volume 88, 40-45, CNCI 2019, Atlantis Press. https://doi.org/10.2991/cnci-19.2019.6

5. Thelin R. (2020). A tutorial on modern multithreading and concurrency in C++. Retrieved from: www.educative.io/blog/modern-multithreading-and-concurrency-in-cpp

6. Сіциліцин Ю. О. (2022). Моделювання змісту дисципліни «Паралельні та розподілені обчислення», Педагогічні науки: теорія та практика, № 4 (44), 23-28. https://doi.org/10.26661/2786-5622-2022-4-03

7. Wilson C. (2019). Multithreading and concurrency fundamentals. Retrieved from: www.educative.io/blog/multithreading-and-concurrency-fundamentals

8. Williams A. (2019). C++ Concurrency in Action, Second Edition. Manning Publications Co. Shelter Island, NY.

9. The Difference Between Asynchronous and Multi-Threading (2023). Retrieved from: www.baeldung.com/cs/async-vs-multi-threading

10. MemarianK.,Matthiesen J., Lingard J.,Nienhuis K., Chisnall D., Watson R.N.M., Sewell P. (2016). Into the depths of C: elaborating the de facto standards, PLDI '16: Proceedings of the 37th ACM SIGPLAN Conference on Programming Language Design and Implementation, 1–15.https://doi.org/10.1145/2908080.2908081

11. Mahapatra S. (2023). Multithreading in C++. Retrieved from: www.geeksforgeeks.org/multithreading-in-cpp 

12. Ajkunic E., Fatkic H., Omerovic E., Talic K., Nosovic N. (2012). A Comparison of Five Parallel Programming Models for C++, 2012 Proceedings of the 35th International Convention, MIPRO 2012, Opatija, Croatia, May 21-25, 2012. IEEE 2012, 1780-1784.