4

Is there any simple way to store thread specific data in Linux Kernel? For example, I want to store some counters for each thread and read/write them from different places in lock free manner. I expected there should be something in thread_info structure, but I was unable to find any good documentation about it.

I know how to make it in Windows kernel, but not sure what is the best what for Linux. Probably, there is also kind of compiler-specific routine to access tls.

Thank you!

jww
  • 97,681
  • 90
  • 411
  • 885
Tutankhamen
  • 3,532
  • 1
  • 30
  • 38
  • [Thread-Local Storage (TLS) support for Linux, 2.5.28](https://lwn.net/Articles/5851/) on LWN. The LWN article also links to a test program at [`tls_test.c`](https://people.redhat.com/mingo/tls-patches/tls_test.c). Also see [Linux's thread local storage implementation](https://stackoverflow.com/q/2459692/608639). – jww Aug 17 '18 at 01:39

0 Answers0