(Linux) set_tid_address vs set_thread_area?
Page 1 of 1

Author:  AndrewAPrice [ Fri May 22, 2020 12:21 pm ]
Post subject:  (Linux) set_tid_address vs set_thread_area?

What is the difference between the two linux syscalls set_tid_address and set_thread_area?

Which one (on x86-64 long mode) updates the fs register?

Author:  Korona [ Fri May 22, 2020 1:30 pm ]
Post subject:  Re: (Linux) set_tid_address vs set_thread_area?

arch_prctl sets the fs register.

Author:  nullplan [ Sun May 24, 2020 10:54 pm ]
Post subject:  Re: (Linux) set_tid_address vs set_thread_area?

To expand on Korona's answer: arch_prctl() can set FS on x86_64. set_thread_area() was the old system call for 32-bit applications to install a thread-local GDT segment that can point anywhere, and that you can then load yourself into whatever segment you wish. set_tid_address() is something else entirely. It sets an address meant to hold the thread's TID. When the thread exits, the kernel sets that address to 0 and performs a futex-wake on the address. This can be used to implement threading libraries. For instance, you can implement pthread_join() by having one thread wait on the TID address of the other thread.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group