November 2024
Intermediate to advanced
424 pages
9h 55m
English
As we learned in the previous two chapters, threads are the smallest and most lightweight units of execution within a program. Each thread takes care of a unique task defined by a sequence of instructions running on allocated CPU resources by the OS scheduler. Threads play a critical role when managing concurrency within a program aiming to maximize the overall utilization of CPU resources.
During the program’s startup process, after the kernel passes the execution to the process, the C++ runtime creates the main thread and executes the main() function. After that, additional threads can be created to split the program into different tasks that can run concurrently and share resources. This way, the ...
Read now
Unlock full access