I am working on a multi-threaded implementation of a library. In one module of this library there are several global variables (very often used when executing a program). To make access to these variables more secure, I announced that they use the __declspec(thread)local storage (TLS) keyword .
Here is the call to the external library function. This function uses a module with global variables:
for(i = 0; i<n_cores; i++)
hth[i] = (HANDLE)_beginthread((void(*)(void*))MT_Interface_DimenMultiCells,0,(void*)&inputSet[i]);
Thus, I think that all the variables used in the library will be duplicated for each thread.
When I run the program on the x8 kernel processor, the time required to complete the operation does not exceed 1/3 of the time required to implement one process.
I know that itβs impossible to reach 1/8 of the time, but I thought that at least 1/6 could be found.
The question is, are these __declspec (thread) variables causing such bad actions?
Thanks in advance, GB
Beppe source
share