OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Mar 02, 2021 8:48 pm

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: 2142
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: 818
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: 854
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.

_________________
Thou hast outraged, not insulted me, sir; but for that I ask thee not to beware of Starbuck; thou wouldst but laugh; but let Ahab beware of Ahab; beware of thyself, old man.


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], Octocontrabass, Schol-R-LEA and 15 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