OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 10:26 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: (Linux) set_tid_address vs set_thread_area?
PostPosted: Fri May 22, 2020 12:21 pm 
Offline
Member
Member
User avatar

Joined: Mon Jun 05, 2006 11:00 pm
Posts: 2293
Location: USA (and Australia)
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?

_________________
My OS is Perception.


Top
 Profile  
 
 Post subject: Re: (Linux) set_tid_address vs set_thread_area?
PostPosted: Fri May 22, 2020 1:30 pm 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
arch_prctl sets the fs register.

_________________
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].


Top
 Profile  
 
 Post subject: Re: (Linux) set_tid_address vs set_thread_area?
PostPosted: Sun May 24, 2020 10:54 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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.

_________________
Carpe diem!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group