Questions tagged [thread-specific-storage]

10 questions
17
votes
2 answers

Thread Specific Data vs Thread Local Storage

I've read Kerrisk's The Linux Programming Interface: A Linux and UNIX System Programming Handbook, Chapter 31 on Threads. The chapter include Thread Specific Data (Section 31.3.4) and Thread Local Storage (Section 31.4). The topics were covered on…
jww
  • 97,681
  • 90
  • 411
  • 885
9
votes
6 answers

pthread_key_create destructor not getting called

As per pthread_key_create man page we can associate a destructor to be called at thread shut down. My problem is that the destructor function I have registered is not being called. Gist of my code is as follows. static pthread_key_t key; static…
chamibuddhika
  • 1,419
  • 2
  • 20
  • 36
4
votes
1 answer

Difference between "thread local storage" and "thread specific storage"

What is the difference between declaring a thread-local variable using the dedicated keyword: _Thread_local int var; And using the specific tss_ set of functions: tss_t key; tss_create(&key, free); tss_set(key, malloc(sizeof(int))); int* pVar =…
DarkAtom
  • 2,589
  • 1
  • 11
  • 27
4
votes
9 answers

Is it possible to *safely* return a TCHAR* from a function?

I've created a function that will convert all the event notification codes to strings. Pretty simple stuff really. I've got a bunch of consts like const _bstr_t DIRECTSHOW_MSG_EC_ACTIVATE("A video window is being activated or deactivated."); const…
John MacIntyre
  • 12,910
  • 13
  • 67
  • 106
3
votes
1 answer

How to use Thread-specific data correctly

I am programming using pthread. I need a global variable that it has different value for different threads. And threads will use same function to deal with this variable, such as change its value. If one thread change its value, the value in other…
0
votes
0 answers

Python multithreading- memory leak when use an shared object(so)

I have a python programs that gets memory leaks when use an third-party SO. I simplify my code like this: import time import sys import threading import codecs import ctypes sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach()) class…
0
votes
0 answers

C++ Thread local storage - same name used in different compilation units

Assume we have the following code in some compilation unit that eventually is compiled to a shared lib on Linux (g++ 4.9) namespace A { class B { static __thread MyObj *myobj; }; } So this is compiled into .so and it does not export…
Kobi
  • 832
  • 1
  • 9
  • 16
0
votes
1 answer

How to iterate through boost thread specific pointers

I have a multi-thread application. Each thread initializes a struct data type in its own local storage. Some elements are being added to the vectors inside the struct type variables. At the end of the program, I would like to iterate through these…
0
votes
1 answer

How does a portable Thread Specific Storage Mechanism's Naming Scheme Generate Thread Relative Unique Identifiers?

A portable thread specific storage reference/identity mechanism, of which boost/thread/tss.hpp is an instance, needs a way to generate a unique keys for itself. This key is unique in the scope of a thread, and is subsequently used to retrieve the…
-1
votes
1 answer

Can I save a value out of my currernt thread?

I met some confusions when writing a C program. My scenario has 2 thread but they run serial, so at one time there's single thread. I want to save a parameter in my first thread and I want to get it in my second thread. (pthread here) So is there…