Introduce pthread_rwlock_try{rd,wr}lock

This also changes recursive mutexes to favor cpu over scheduler yield.
This commit is contained in:
Justine Tunney 2023-10-31 21:59:05 -07:00
parent a1e1e821cb
commit fadb64a2bf
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
13 changed files with 122 additions and 29 deletions

View file

@ -17,12 +17,13 @@
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/atomic.h"
#include "libc/nexgen32e/yield.h"
#include "libc/thread/posixthread.internal.h"
int _pthread_tid(struct PosixThread *pt) {
int tid = 0;
while (pt && !(tid = atomic_load_explicit(&pt->ptid, memory_order_acquire))) {
pthread_yield();
spin_yield();
}
return tid;
}