October 2018
Beginner
794 pages
19h 23m
English
To demonstrate exactly this issue (actually seeing the data race), we will write another demo program. In this one, we will calculate the factorial of a given number (a quick reminder: 3! = 3 x 2 x 1 = 6; recall from your school days—the notation N! means factorial of N). Here's the relevant code:
In main(), we initialize our mutex lock (and create two worker threads; we do not show the code to create the threads, destroy them, as well as the mutex):
printf( ...
Read now
Unlock full access