Back in February of 2010 I wrote a simple program to count all the prime numbers between 2 and 232. It use pthreads so I could fully utilize the duel processor Red-Dragon. The C11 standard introduced threads right into the language. Several years ago I thought I'd port my prime counting program to use this because any system that supported the full C11 standard would be able to compile and run it. Sadly I discovered that gcc had not implemented C11 threads at that time. However, as of version GCC 9.3.0 C11 threads are present—you just have to link with the pthreads library as it uses pthreads under the hood.
Porting didn't take too long. However, there was one item I did not have from the start that I would need: counting semaphores. Counting semaphores are used by the program to keep some specified number of running threads—typically one thread for each core of the CPU. The C11 threads implementation does have mutexes and c conditional waits and those can be used to make a counting semaphore. So I wrote a very simple header file with inline functions for counting semaphores.
The implementation is nearly identical, just using the C11 thread structures and my semaphore unit. I don't know the speeds of the original Red Dragon, but I ran a speed test in May of 2017. My fastest machine at the time, a duel-core 4-thread Intel i7, required 28.26 minutes. My AMD Ryzen 7 1700, 8-core/16-thread CPU needs 16.58 minutes.