mirror of
https://github.com/mmueller41/genode.git
synced 2026-01-21 20:42:56 +01:00
Add 'Thread_base::join()'
Using the new 'join()' function, the caller can explicitly block for the completion of the thread's 'entry()' function. The test case for this feature can be found at 'os/src/test/thread_join'. For hybrid Linux/Genode programs, the 'Thread_base::join()' does not map directly to 'pthread_join'. The latter function gets already called by the destructor of 'Thread_base'. According to the documentation, subsequent calls of 'pthread_join' for one thread may result in undefined behaviour. So we use a 'Genode::Lock' on this platform, which is in line with the other platforms. Related to #194, #501
This commit is contained in:
@@ -254,6 +254,11 @@ namespace Genode {
|
||||
*/
|
||||
Native_thread _tid;
|
||||
|
||||
/**
|
||||
* Lock used for synchronizing the finalization of the thread
|
||||
*/
|
||||
Genode::Lock _join_lock;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -335,6 +340,14 @@ namespace Genode {
|
||||
* 0 when called by the main thread.
|
||||
*/
|
||||
Native_utcb *utcb();
|
||||
|
||||
/**
|
||||
* Block until the thread leaves the 'entry' function
|
||||
*
|
||||
* Join must not be called more than once. Subsequent calls have
|
||||
* undefined behaviour.
|
||||
*/
|
||||
void join();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user