summaryrefslogtreecommitdiff
path: root/src/thread/pthread_self.c
AgeCommit message (Collapse)AuthorLines
2011-09-13remove some stray trailing space charactersRich Felker-1/+1
2011-08-06simplify multi-threaded errno, eliminate useless function pointerRich Felker-7/+2
2011-07-30add proper fuxed-based locking for stdioRich Felker-0/+2
previously, stdio used spinlocks, which would be unacceptable if we ever add support for thread priorities, and which yielded pathologically bad performance if an application attempted to use flockfile on a key file as a major/primary locking mechanism. i had held off on making this change for fear that it would hurt performance in the non-threaded case, but actually support for recursive locking had already inflicted that cost. by having the internal locking functions store a flag indicating whether they need to perform unlocking, rather than using the actual recursive lock counter, i was able to combine the conditionals at unlock time, eliminating any additional cost, and also avoid a nasty corner case where a huge number of calls to ftrylockfile could cause deadlock later at the point of internal locking. this commit also fixes some issues with usage of pthread_self conflicting with __attribute__((const)) which resulted in crashes with some compiler versions/optimizations, mainly in flockfile prior to pthread_create.
2011-04-20fix minor bugs due to incorrect threaded-predicate semanticsRich Felker-4/+2
some functions that should have been testing whether pthread_self() had been called and initialized the thread pointer were instead testing whether pthread_create() had been called and actually made the program "threaded". while it's unlikely any mismatch would occur in real-world problems, this could have introduced subtle bugs. now, we store the address of the main thread's thread descriptor in the libc structure and use its presence as a flag that the thread register is initialized. note that after fork, the calling thread (not necessarily the original main thread) is the new main thread.
2011-04-17debloat: use __syscall instead of syscall where possibleRich Felker-1/+1
don't waste time (and significant code size due to function call overhead!) setting errno when the result of a syscall does not matter or when it can't fail.
2011-04-17optimize cancellation enable/disable codeRich Felker-0/+1
the goal is to be able to use pthread_setcancelstate internally in the implementation, whenever a function might want to use functions which are cancellation points but avoid becoming a cancellation point itself. i could have just used a separate internal function for temporarily inhibiting cancellation, but the solution in this commit is better because (1) it's one less implementation-specific detail in functions that need to use it, and (2) application code can also get the same benefit. previously, pthread_setcancelstate dependend on pthread_self, which would pull in unwanted thread setup overhead for non-threaded programs. now, it temporarily stores the state in the global libc struct if threads have not been initialized, and later moves it if needed. this way we can instead use __pthread_self, which has no dependencies and assumes that the thread register is already valid.
2011-04-01use bss instead of mmap for main thread's pthread thread-specific dataRich Felker-9/+3
this simplifies code and removes a failure case
2011-03-20global cleanup to use the new syscall interfaceRich Felker-1/+1
2011-03-09optimize pthread initializationRich Felker-2/+2
the set_tid_address returns the tid (which is also the pid when called from the initial thread) so there is no need to make a separate syscall to get pid/tid.
2011-03-03optimize POSIX TSD for fast pthread_getspecificRich Felker-0/+11
2011-02-15finish unifying thread register handling in preparation for portingRich Felker-9/+3
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+39