Take a normal recursive mutex as an example, if I lock and unlock it correctly in a thread, it will be put into robust list in pthread_mutex_lock and get removed from the list in pthread_mutex_unlock(). If I lock it but miss to unlock, it will be still in robust list and processed in pthread_exit(). But in both cases, I did not find that the presence of the robust list had any impact on this mutex. Does it not need to be put into the robust list.
Sender:"Markus Wichmann"< nullplan@gmx.net >;
Sent Time:2024/5/24 21:58
To:"musl"< musl@lists.openwall.com >;
Cc recipient:"AK47"< 250200715@qq.com >;
Subject:Re: [musl] Pthread robust_list for non-pshared mutexes
Hi,
not entirely sure what you mean. All non-normal mutexes get added to the
robust list, yes, but also get removed from the list in
pthread_mutex_unlock(). And the robust list is processed in
pthread_exit(), which all threads must call sooner or later. Only
exception is when a thread crashes, but in that case the entire process
dies, and non-pshared mutexes cease to matter.
If a thread is cancelled, __cancel() will call pthread_exit(). And I
know of no other way for a thread to "end" as you put it.
Ciao,
Markus