Page MenuHomeFreeBSD

Add pthread_peekjoin_np(3).
ClosedPublic

Authored by kib on Feb 13 2020, 11:46 PM.
Tags
None
Referenced Files
F82000495: D23676.id68291.diff
Wed, Apr 24, 9:08 AM
F81996241: D23676.id.diff
Wed, Apr 24, 7:45 AM
Unknown Object (File)
Mar 11 2024, 6:25 AM
Unknown Object (File)
Mar 9 2024, 6:22 AM
Unknown Object (File)
Mar 9 2024, 6:21 AM
Unknown Object (File)
Mar 9 2024, 6:17 AM
Unknown Object (File)
Mar 9 2024, 6:17 AM
Unknown Object (File)
Mar 7 2024, 10:14 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 29367

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.