- Pthread Tutorials: https://computing.llnl.gov/tutorials/pthreads/
- OpenSSL Library: www.openssl.org
There are good practices that i recommend you to read them(this list will update as soon as new practices i find):
In Summary volatile keyword in Java is not a replacement of synchronized block or method but in some situation is very handy and can save performance overhead which comes with use of synchronization in Java
CPU affinity ( or processor affinity ) is an ability provided by operating systems such as Windows or Linux that allows you to select specific CPUs or processors to run your program/application on. In a multi-core and multi-processor system, the assignment of a process to a CPU/processor is automatically decided by the OS via its scheduler. However, you still can interfere in this scheduling task by specifying a CPU that your program will be run on.
Why CPU affinity is needed ?
You may ask “Why do I need it if OS is hanlding everything for me?”. You are right. In most cases, you won’t need this function. However, if the runtime performance is your concern, in some cases, it’s worth a try to decide whether to use CPU affinity. For demonstration, I wrote a simple parallel program doing some computations using multi-cores. When I ran this program on a 12-core machine (two prossesors , six cores per processor) with/without CPU affinity, I got below runtime performance.
CPU affinity improves the runtime performance because it optimizes cache performance by reducing cache miss. In a NUMA system, setting CPU affinity and allocating memory also on the faster RAM can speed up the process as well.
How to ?
There are two ways to set the CPU affinity in both Linux and Windows.
Method 1: Set the CPU affinity using Task manager
Method 1: Launch the program from the command line using settask
The below command will launch gedit in CPU 1 & 4 (or 0 and 3).
taskset -c 0,3 gedit
Method 2: Second, program from your source code
You can use the function sched_setaffinity in sched.h to manage CPU affinity from your code