Opened 15 years ago
Closed 8 years ago
#5694 closed enhancement (fixed)
Implement pthread barriers
Reported by: | bonefish | Owned by: | Barrett |
---|---|---|---|
Priority: | normal | Milestone: | Unscheduled |
Component: | System/POSIX | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
Implement pthread barrier functions (pthread_barrier*()).
Attachments (1)
Change History (13)
comment:1 by , 10 years ago
Milestone: | R1 → Unscheduled |
---|
comment:2 by , 8 years ago
From http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html
PTHREAD_BARRIER_SERIAL_THREAD pthread_barrier_t pthread_barrierattr_t int pthread_barrier_destroy(pthread_barrier_t *); int pthread_barrier_init(pthread_barrier_t *restrict, const pthread_barrierattr_t *restrict, unsigned); int pthread_barrier_wait(pthread_barrier_t *); int pthread_barrierattr_destroy(pthread_barrierattr_t *); int pthread_barrierattr_init(pthread_barrierattr_t *);
are to be declared in headers/posix/pthread.h, implemented in headers/private/libroot/pthread_private.h and src/system/libroot/posix/pthread
pthread barriers are no longer an extension.
Also we shouldn't define PTHREAD_BARRIER_SERIAL_THREAD when we don't support this feature. For instance, CMake 3.7 checks whether PTHREAD_BARRIER_SERIAL_THREAD is defined to import an pthread barrier private implementation.
comment:3 by , 8 years ago
patch: | 0 → 1 |
---|
comment:4 by , 8 years ago
For the past two days, I was torn between implementing things from scratch, using pthread_cond and pthread_mutex to keep the code cleaner, and going back to reimplementing them from scratch to avoid wasting memory (sizeof(pthread_barrier_t)
: 64 bytes (!) vs 20 bytes in current implementation). This is what I settled on.
comment:6 by , 8 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 8 years ago
patch: | 1 → 0 |
---|
comment:8 by , 8 years ago
patch: | 0 → 1 |
---|
comment:9 by , 8 years ago
Seems pretty good to me. A testcase in src/tests/system/libroot/posix would help to see which cases you've tested.
comment:10 by , 8 years ago
I added a test in src/tests/system/libroot/posix/pthread_barrier_test.cpp
comment:11 by , 8 years ago
Could you add a blank line at line 5 of pthread_barrier.cpp? The testcase seems OK.
by , 8 years ago
Attachment: | 0001-Implemented-pthread-barriers.patch added |
---|
My implementation of pthread barriers
comment:12 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Thanks. I edited a little bit (order of includes, commit message and left out a else) and applied in hrev50804.
Move POSIX compatibility related tickets out of R1 milestone (FutureHaiku/Features).