History log of /haiku/src/system/libroot/os/thread.c
Revision Date Author Comments
# 914b10c1 11-Mar-2022 Jessica Hamilton <jessica.l.hamilton@gmail.com>

wait_for_thread_etc: expose as syscall/make public.

* This will be needed for the following commit that implements
`pthread_tryjoin_np` and `pthread_timedjoin_np`.

Change-Id: Idccb1aa588d6d10825294d14925d9bd046b65f19
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5098
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# a44af2ec 05-Mar-2021 Jérôme Duval <jerome.duval@gmail.com>

libroot: call thread exit hooks before destroying tls

Change-Id: Ide2799ccf8620e42650a8f45177fb5fac4f09696
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3762
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>


# 3b5e6232 25-Dec-2018 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Fix GCC2 build.


# e4103b1b 25-Dec-2018 Michael Lotz <mmlr@mlotz.ch>

libroot: Introduce thread specific heap init/exit hooks.

This allows heap implementations to initialize and clean up any thread
specific structures. The current default hoard heap does not use these.

Note that the thread exit hook will not be called for the main thread as
the heap may be needed during process termination (__cxa_finalize for
example).

Change-Id: I703fbd34dec0d9029d619a2125c5b19d8c1933aa
Reviewed-on: https://review.haiku-os.org/799
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 44c0c4d3 03-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

runtime_loader: add support for ELF based TLS

This patch introduces support of ELF based TLS handling with lazy allocation
and initalization of TLS block for each DSO and thread. The implementation
generally follows the official ABI except that generation counter in dtv
is in fact a pointer to Generation object that contains both generation
counter and size of the dtv. That simplified the implementation a bit, but
could be changed later. The ABI requirements regariding in memory position
of TLS block is not honoured what results in static TLS model being
unsupported. However, that should not be a problem as long as
"executables" in Haiku are in fact shared objects and optimizations which
require specific TLS block in memory layout are not possible anyway.


# 1bc85a38 26-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

libroot: spawn_thread() now creates a detached pthread.

* __pthread_destroy_thread() will in turn free the pthread_thread object.
* this fixes a leak of 2072 bytes on each thread construction/destruction
and #9945. MediaExtractor spawns a thread on construction, which leaked
its pthread_thread object on destuction.


# 07e1875e 15-May-2013 Pawel Dziepak <pdziepak@quarnos.org>

libroot: explicitly check ABI version

As Axel suggested use simple, explicit checks for legacy ABI version
instead of obscure "compatibility mode".


# 5d0a1da8 14-May-2013 Pawel Dziepak <pdziepak@quarnos.org>

libroot: make all areas executable for old binaries

* If at least one image is either B_HAIKU_ABI_GCC_2_ANCIENT or
B_HAIKU_ABI_GCC_2_BEOS almost all areas are marked as executable.
* B_EXECUTE_AREA and B_STACK_AREA are made public. The former is enforced since
the introduction of DEP and apps need it to correctly set area protection.
The latter is currently needed only to recognize stack areas and fix their
protection in compatibility mode, but may also be useful if an app wants
to use sigaltstack from POSIX API.


# 24df6592 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 85b2f68b 24-Feb-2011 Philippe Saint-Pierre <stpere@gmail.com>

Fix build on gcc2.
(Note, I honestly have no idea what was initially wrong with the code; everything seamt right to me..)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40676 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3a04b749 24-Feb-2011 Jérôme Duval <korli@users.berlios.de>

Don't dereference thread after free(). Thanks to Stephan for noticing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40674 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bafa7591 24-Feb-2011 Jérôme Duval <korli@users.berlios.de>

now correctly init the thread id in the pthread struct for main thread and threads spawned with spawn_thread(). This definitely helps for #7235.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40665 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ceee0a32 06-Nov-2010 François Revol <revol@free.fr>

Fix warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39328 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 585a28af 18-Jan-2010 Jérôme Duval <korli@users.berlios.de>

I thought afterwards the stub can still be useful to run R5 C only binaries on a GCC4 Haiku. It might be better placed in the arch folder though.
Also fixed a typo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35146 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35c16bd3 18-Jan-2010 Adrien Destugues <pulkomandy@pulkomandy.ath.cx>

DeadYak over IRC:
-Fix gcc4 build


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35145 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4248cf5 18-Jan-2010 Jérôme Duval <korli@users.berlios.de>

* Rename _thread_do_exit_notification() to _thread_do_exit_work() as suggested by Ingo.
Also added an empty stub for _thread_do_exit_notification() when compiling for GCC2.
* Removed the check testing if the thread is already dead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35142 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ecf6b86c 09-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* The pthread_thread structure is now allocated for all threads.
* Therefore, all pthread functions should now work fine on all threads.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33967 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89cfd542 04-Sep-2008 Karsten Heimrich <host.haiku@gmx.de>

* revert r27322 and apply the patch provided by Salvatore
Thanks you! :)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27323 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 754b7065 04-Sep-2008 Karsten Heimrich <host.haiku@gmx.de>

* calling receive_data with NULL as first argument(thread_id)
failed on Haiku, this makes e.g. painting in ArtPaint work

Don't know if this is the best place to fix it though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27322 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6b202f4e 13-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced new header directory headers/private/system which is supposed
to contain headers shared by kernel and userland (mainly libroot).
* Moved quite a few private kernel headers to the new location. Split
several kernel headers into a shared part and one that is still kernel
private. Adjusted all affected Jamfiles and source in the standard x86
build accordingly. The build for other architectures and for test code
may be broken.
* Quite a bit of userland code still includes private kernel headers.
Mostly those are <util/*> headers. The ones that aren't strictly
kernel-only should be moved to some other place (maybe
headers/private/shared/util).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25486 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4c49f205 08-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed _kern_spawn_thread() and create_thread(): Instead of individual
arguments they get a single thread_creation_attributes structure now.
* Added stack_address and stack_size to thread_creation_attributes,
which allow to specify the stack size or the stack to be used for the
new user thread.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25389 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 392ad282 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
BeOS R5's glue code incorrectly calls _thread_do_exit_notification()
when main() returns, while Haiku does that in exit(). Therefore when
terminating this way the exit hooks were called twice for executables
built under BeOS R5. This caused e.g. NetPositive or the R5 svn to
crash on exit (our network code actually uses those hooks).
Fixes bug #1742.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23975 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 794df3bf 20-Aug-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

This removes the inline assembly code for find_thread
from OS.h, sorry for triggering a complete rebuild.
To avoid doing a syscall for find_thread(0), the assembly
version is now in libroot. For BeOS R5 compatibility,
_kfind_thread_ is retained. This will fix some compile
problems, and provides a cleaner OS.h for future Haiku
versions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14014 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 183dee22 12-Jun-2005 Axel Dörfler <axeld@pinc-software.de>

Unlike R5, receive_data() could return an error code under Haiku - this
can now only happen if the thread is killed.
_user_receive_data() will now longer pass B_CAN_INTERRUPT to receive_data(),
but B_KILL_CAN_INTERRUPT - this should fix the problem Stefano experienced
with this function, even if I couldn't reproduce it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13075 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5af32e75 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed src/kernel to src/system.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12359 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 44c0c4d3d0d68c3c3db23858b1089d3cf51bdf16 03-May-2014 Pawel Dziepak <pdziepak@quarnos.org>

runtime_loader: add support for ELF based TLS

This patch introduces support of ELF based TLS handling with lazy allocation
and initalization of TLS block for each DSO and thread. The implementation
generally follows the official ABI except that generation counter in dtv
is in fact a pointer to Generation object that contains both generation
counter and size of the dtv. That simplified the implementation a bit, but
could be changed later. The ABI requirements regariding in memory position
of TLS block is not honoured what results in static TLS model being
unsupported. However, that should not be a problem as long as
"executables" in Haiku are in fact shared objects and optimizations which
require specific TLS block in memory layout are not possible anyway.


# 1bc85a38d543589e6094ed27cf410f69540b35c4 26-Sep-2013 Jérôme Duval <jerome.duval@gmail.com>

libroot: spawn_thread() now creates a detached pthread.

* __pthread_destroy_thread() will in turn free the pthread_thread object.
* this fixes a leak of 2072 bytes on each thread construction/destruction
and #9945. MediaExtractor spawns a thread on construction, which leaked
its pthread_thread object on destuction.


# 07e1875ea21bd0a05e949cce0d4e4558b6684ee0 15-May-2013 Pawel Dziepak <pdziepak@quarnos.org>

libroot: explicitly check ABI version

As Axel suggested use simple, explicit checks for legacy ABI version
instead of obscure "compatibility mode".


# 5d0a1da8bf914d4a26bba97ba40cbb36bf99ce52 14-May-2013 Pawel Dziepak <pdziepak@quarnos.org>

libroot: make all areas executable for old binaries

* If at least one image is either B_HAIKU_ABI_GCC_2_ANCIENT or
B_HAIKU_ABI_GCC_2_BEOS almost all areas are marked as executable.
* B_EXECUTE_AREA and B_STACK_AREA are made public. The former is enforced since
the introduction of DEP and apps need it to correctly set area protection.
The latter is currently needed only to recognize stack areas and fix their
protection in compatibility mode, but may also be useful if an app wants
to use sigaltstack from POSIX API.


# 24df65921befcd0ad0c5c7866118f922da61cb96 11-Jun-2011 Ingo Weinhold <ingo_weinhold@gmx.de>

Merged signals-merge branch into trunk with the following changes:
* Reorganized the kernel locking related to threads and teams.
* We now discriminate correctly between process and thread signals. Signal
handlers have been moved to teams. Fixes #5679.
* Implemented real-time signal support, including signal queuing, SA_SIGINFO
support, sigqueue(), sigwaitinfo(), sigtimedwait(), waitid(), and the addition
of the real-time signal range. Closes #1935 and #2695.
* Gave SIGBUS a separate signal number. Fixes #6704.
* Implemented <time.h> clock and timer support, and fixed/completed alarm() and
[set]itimer(). Closes #5682.
* Implemented support for thread cancellation. Closes #5686.
* Moved send_signal() from <signal.h> to <OS.h>. Fixes #7554.
* Lots over smaller more or less related changes.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42116 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 85b2f68b69be9dba5c645ef4bd0e7107f5460e2d 24-Feb-2011 Philippe Saint-Pierre <stpere@gmail.com>

Fix build on gcc2.
(Note, I honestly have no idea what was initially wrong with the code; everything seamt right to me..)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40676 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3a04b7492290359b8ba05eef99f3b32336973852 24-Feb-2011 Jérôme Duval <korli@users.berlios.de>

Don't dereference thread after free(). Thanks to Stephan for noticing.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40674 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bafa759148a8c7d7ee34164591511930cac4e8f7 24-Feb-2011 Jérôme Duval <korli@users.berlios.de>

now correctly init the thread id in the pthread struct for main thread and threads spawned with spawn_thread(). This definitely helps for #7235.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40665 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ceee0a32a4cf041f69a232f4d0986718bd6390e2 06-Nov-2010 François Revol <revol@free.fr>

Fix warning.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39328 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 585a28af7b7acc8bfe270f4d4f7db298d02d417e 18-Jan-2010 Jérôme Duval <korli@users.berlios.de>

I thought afterwards the stub can still be useful to run R5 C only binaries on a GCC4 Haiku. It might be better placed in the arch folder though.
Also fixed a typo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35146 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35c16bd3fecd7ee8baae8ab83124e36af9a2731d 18-Jan-2010 Adrien Destugues <pulkomandy@pulkomandy.ath.cx>

DeadYak over IRC:
-Fix gcc4 build


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35145 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a4248cf53b4dc9a6f602201c96c9f4a5c03276c5 18-Jan-2010 Jérôme Duval <korli@users.berlios.de>

* Rename _thread_do_exit_notification() to _thread_do_exit_work() as suggested by Ingo.
Also added an empty stub for _thread_do_exit_notification() when compiling for GCC2.
* Removed the check testing if the thread is already dead.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35142 a95241bf-73f2-0310-859d-f6bbb57e9c96


# ecf6b86c92e0d25ab16870477dce21531a7faee8 09-Nov-2009 Axel Dörfler <axeld@pinc-software.de>

* The pthread_thread structure is now allocated for all threads.
* Therefore, all pthread functions should now work fine on all threads.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33967 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 89cfd54279e8ce6d5432e60e8ba3d881d40fd3d5 04-Sep-2008 Karsten Heimrich <host.haiku@gmx.de>

* revert r27322 and apply the patch provided by Salvatore
Thanks you! :)



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27323 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 754b7065196871546f79e4fd2cad089b511562fb 04-Sep-2008 Karsten Heimrich <host.haiku@gmx.de>

* calling receive_data with NULL as first argument(thread_id)
failed on Haiku, this makes e.g. painting in ArtPaint work

Don't know if this is the best place to fix it though.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27322 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 6b202f4e3da73d4c131355fcd82b792d153f84f6 13-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Introduced new header directory headers/private/system which is supposed
to contain headers shared by kernel and userland (mainly libroot).
* Moved quite a few private kernel headers to the new location. Split
several kernel headers into a shared part and one that is still kernel
private. Adjusted all affected Jamfiles and source in the standard x86
build accordingly. The build for other architectures and for test code
may be broken.
* Quite a bit of userland code still includes private kernel headers.
Mostly those are <util/*> headers. The ones that aren't strictly
kernel-only should be moved to some other place (maybe
headers/private/shared/util).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25486 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 4c49f2056bbec860092e8c26520398b4121f8d1a 08-May-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

* Changed _kern_spawn_thread() and create_thread(): Instead of individual
arguments they get a single thread_creation_attributes structure now.
* Added stack_address and stack_size to thread_creation_attributes,
which allow to specify the stack size or the stack to be used for the
new user thread.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25389 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 392ad2822da8cad9aac55bcf327bb660f1f49b08 17-Feb-2008 Ingo Weinhold <ingo_weinhold@gmx.de>

axeld + bonefish:
BeOS R5's glue code incorrectly calls _thread_do_exit_notification()
when main() returns, while Haiku does that in exit(). Therefore when
terminating this way the exit hooks were called twice for executables
built under BeOS R5. This caused e.g. NetPositive or the R5 svn to
crash on exit (our network code actually uses those hooks).
Fixes bug #1742.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23975 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 794df3bf254c03b363a5d196456a429b89a71855 20-Aug-2005 Marcus Overhagen <marcusoverhagen@gmail.com>

This removes the inline assembly code for find_thread
from OS.h, sorry for triggering a complete rebuild.
To avoid doing a syscall for find_thread(0), the assembly
version is now in libroot. For BeOS R5 compatibility,
_kfind_thread_ is retained. This will fix some compile
problems, and provides a cleaner OS.h for future Haiku
versions.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14014 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 183dee22cb21a6c4cde5423c90c408a078126cb1 12-Jun-2005 Axel Dörfler <axeld@pinc-software.de>

Unlike R5, receive_data() could return an error code under Haiku - this
can now only happen if the thread is killed.
_user_receive_data() will now longer pass B_CAN_INTERRUPT to receive_data(),
but B_KILL_CAN_INTERRUPT - this should fix the problem Stefano experienced
with this function, even if I couldn't reproduce it.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13075 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 5af32e752606778be5dd7379f319fe43cb3f6b8c 13-Apr-2005 Axel Dörfler <axeld@pinc-software.de>

Renamed src/kernel to src/system.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12359 a95241bf-73f2-0310-859d-f6bbb57e9c96