summaryrefslogtreecommitdiff
path: root/lib/libthr/thread/thr_stack.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-261-1/+3
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using mis-identified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326219
* libthr: Use CLI flags instead of pragmas to disable warningsEric van Gyzen2017-05-201-17/+0
| | | | | | | | | | | | | | | | | | People tweaking the build system or compilers tend to look into the Makefile and not into the source. Having some warning controls in the Makefile and some in the source code is surprising. Pragmas have the advantage that they leave the warnings enabled for more code, but that advantage isn't very relevant in these cases. Requested by: kib Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10832 Notes: svn path=/head/; revision=318584
* libthr: fix warnings at WARNS=6Eric van Gyzen2017-05-191-0/+17
| | | | | | | | | | | | | | | | | | | Fix warnings about the following when WARNS=6 (which I will commit soon): - casting away const - no previous 'extern' declaration for non-static variable - others as explained by #pragmas and comments - unused parameters The last is the only functional change. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10808 Notes: svn path=/head/; revision=318539
* Use __FBSDID() for .c files from lib/libthr/thread.Konstantin Belousov2016-04-081-2/+3
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=297706
* If libthr.so is dlopened without RTLD_GLOBAL flag, the libthr symbolsKonstantin Belousov2016-02-081-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | do not participate in the global symbols namespace, but rtld locks are still replaced and functions are interposed. In particular, __pthread_map_stacks_exec is resolved to the libc version. If a library is loaded later, which requires adjustment of the stack protection mode, rtld calls into libc __pthread_map_stacks_exec due to the symbols scope. The libc version might recurse into binder and recursively acquire rtld bind lock, causing the hang. Make libc __pthread_map_stacks_exec() interposed, which synchronizes rtld locks and version of the stack exec hook when libthr loaded, regardless of the symbol scope control or symbol resolution order. The __pthread_map_stacks_exec() symbol is removed from the private version in libthr since libc symbol now operates correctly in presence of libthr. Reported and tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Notes: svn path=/head/; revision=295407
* Add a knob LIBPTHREAD_BIGSTACK_MAIN, which instructs libthr to leaveKonstantin Belousov2014-08-131-1/+4
| | | | | | | | | | | | | | | | | | | | the whole RLIMIT_STACK-sized region of the kernel-allocated stack as the stack of main thread. By default, the main thread stack is clamped at 2MB (4MB on 64bit ABIs) and the rest is used for other threads stack allocation. Since there is no programmatic way to adjust the size of the main thread stack, pthread_attr_setstacksize() is too late, the knob allows user to manage the main stack size both for single-threaded and multi-threaded processes with the rlimit. Reported by: "Ivan A. Kosarev" <ivan@ivan-labs.com> Tested by: dim Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=269909
* Style.Konstantin Belousov2014-08-131-1/+1
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=269908
* For the process that already loaded libthr but still not initializedKonstantin Belousov2011-01-101-0/+26
| | | | | | | | | | threading, fall back to libc method of performing __pthread_map_stacks_exec() job. Reported and tested by: Mykola Dzham <i levsha me> Notes: svn path=/head/; revision=217224
* Implement the __pthread_map_stacks_exec() for libthr.Konstantin Belousov2011-01-091-1/+34
| | | | | | | | | | | | | | | Stack creation code is changed to call _rtld_get_stack_prot() to get the stack protection right. There is a race where thread is created during dlopen() of dso that requires executable stacks. Then, _rtld_get_stack_prot() may return PROT_READ | PROT_WRITE, but thread is still not linked into the thread list. In this case, the callback misses the thread stack, and rechecks the required protection afterward. Reviewed by: davidxu Notes: svn path=/head/; revision=217191
* Convert thread list lock from mutex to rwlock.David Xu2010-09-131-1/+1
| | | | Notes: svn path=/head/; revision=212536
* WARNS level 4 cleanup.David Xu2006-04-041-3/+4
| | | | Notes: svn path=/head/; revision=157457
* Import my recent 1:1 threading working. some features improved includes:David Xu2005-04-021-105/+125
| | | | | | | | | | | | | | | | | | | 1. fast simple type mutex. 2. __thread tls works. 3. asynchronous cancellation works ( using signal ). 4. thread synchronization is fully based on umtx, mainly, condition variable and other synchronization objects were rewritten by using umtx directly. those objects can be shared between processes via shared memory, it has to change ABI which does not happen yet. 5. default stack size is increased to 1M on 32 bits platform, 2M for 64 bits platform. As the result, some mysql super-smack benchmarks show performance is improved massivly. Okayed by: jeff, mtm, rwatson, scottl Notes: svn path=/head/; revision=144518
* Increase the default stacksizes:Joe Marcus Clarke2005-03-061-6/+6
| | | | | | | | | | | | 32-bit 64-bit main thread 2 MB 4 MB other threads 1 MB 2 MB Approved by: mtm Adapted from: libpthread Notes: svn path=/head/; revision=143170
* Don't include sys/user.h merely for its side-effect of recursivelyDavid Schultz2004-11-271-1/+0
| | | | | | | including other headers. Notes: svn path=/head/; revision=138129
* Decouple the thread stack [de]allocating functions from the 'dead threads list'Mike Makonnen2003-05-261-4/+4
| | | | | | | | | | lock. It's not really necessary and we don't need the added complexity or potential for deadlocks. Approved by: re/blanket libthr Notes: svn path=/head/; revision=115315
* Start locking up the active and dead threads lists. The active threadsMike Makonnen2003-05-251-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | list is protected by a spinlock_t, but the dead list uses a pthread_mutex because it is necessary to synchronize other threads with the garbage collector thread. Lock/Unlock macros are used so it's easier to make changes to the locks in the future. The 'dead thread list' lock is intended to replace the gc mutex. This doesn't have any practical ramifications. It simply makes it clearer what the purpose of the lock is. The gc will use this lock, instead of the gc mutex, to synchronize access to the dead list with other threads. Modify _pthread_exit() to use these two new locks instead of GIANT_LOCK, and also to properly lock and protect thread state changes, especially with respect to a joining thread. The gc thread was also re-arranged to be more organized and less nested. _pthread_join() was also modified to use the thread list locks. However, locking and unlocking here needs special care because a thread could find itself in a position where it's joining an exiting thread that is waiting on the dead list lock, which this thread (joiner) holds. If the joiner doesn't take care to lock *and* unlock in the same order they (the joiner and the joinee) could deadlock against each other. Approved by: re/blanket libthr Notes: svn path=/head/; revision=115305
* - Add libthr but don't hook it up to the regular build yet. This is anJeff Roberson2003-04-011-0/+240
adaptation of libc_r for the thr system call interface. This is beta quality code. Notes: svn path=/head/; revision=112918