Page MenuHomeFreeBSD

Add pthread_peekjoin_np(3).
ClosedPublic

Authored by kib on Feb 13 2020, 11:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 12, 7:38 PM
Unknown Object (File)
Oct 9 2024, 1:20 PM
Unknown Object (File)
Sep 24 2024, 9:22 AM
Unknown Object (File)
Sep 24 2024, 4:58 AM
Unknown Object (File)
Sep 23 2024, 4:11 PM
Unknown Object (File)
Sep 20 2024, 6:26 PM
Unknown Object (File)
Sep 17 2024, 1:50 PM
Unknown Object (File)
Sep 9 2024, 3:28 PM
Subscribers

Details

Summary

See man page for details. In short, the function allows to peek at the thread exit status and even see return value, without joining the target.

I wrote some tests for cancellation and needed a way to non-destructively see the exit state of the thread.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 29368

Event Timeline

I see that Linux has a non-blocking join, pthread_tryjoin_np(). Is that not sufficient for your purposes?

share/man/man3/pthread_join.3
40

Maybe "inspect thread termination state"?

98

"If the thread has not exited, the ..."

155

"did not yet exit" or "has not yet exited". I think the second one is more consistent with the rest of the man page.

kib marked 3 inline comments as done.Feb 14 2020, 6:54 PM

I see that Linux has a non-blocking join, pthread_tryjoin_np(). Is that not sufficient for your purposes?

The tryjoin() method joins, while peekjoin() keeps the thread unjoined, which allows to peek or join again. The use for me was to see whether the thread exited, without disrupting an existing code that joined.

Our timedjoin() can be used as tryjoin() by providing the time in past. I can implement tryjoin() as well, if it is considered worth having explicit interface, to be source-compatible with Linux.

Man page edits.
Add symlink for man.

In D23676#520058, @kib wrote:

I see that Linux has a non-blocking join, pthread_tryjoin_np(). Is that not sufficient for your purposes?

The tryjoin() method joins, while peekjoin() keeps the thread unjoined, which allows to peek or join again. The use for me was to see whether the thread exited, without disrupting an existing code that joined.

Our timedjoin() can be used as tryjoin() by providing the time in past. I can implement tryjoin() as well, if it is considered worth having explicit interface, to be source-compatible with Linux.

Ok. I don't really think it's necessary to implement the Linux extension without some candidate consumer. I was more just wondering how exactly your tests rely on the non-destructive behaviour of peekjoin.

This revision is now accepted and ready to land.Feb 14 2020, 7:29 PM

It was a test for r357894. The victim thread exiting, then I need to wait for it to exit but not join, to issue cancellation request.

This revision was automatically updated to reflect the committed changes.