Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

posix: Fix pthread_barrier_wait() return value #9976

Closed

Conversation

andyross
Copy link
Contributor

The return value from this function is supposed to return
"PTHREAD_BARRIER_SERIAL_WAIT" from exactly one of the calling threads,
otherwise zero or an error code.

Fixes #9953

Signed-off-by: Andy Ross andrew.j.ross@intel.com

The return value from this function is supposed to return
"PTHREAD_BARRIER_SERIAL_WAIT" from exactly one of the calling threads,
otherwise zero or an error code.

Fixes zephyrproject-rtos#9953

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
@@ -11,7 +11,7 @@

int pthread_barrier_wait(pthread_barrier_t *b)
{
int key = irq_lock();
int key = irq_lock(), ret, serial = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not unless I'm missing something. ret needs to match the return type of the function, and serial is just a flag that is 0 or 1 depending on whether this is the last thread to arrive.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am talking about return of irq_lock

}
}

#define PTHREAD_BARRIER_SERIAL_THREAD 0
Copy link

@nniranjhana nniranjhana Sep 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, according to doc

The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in <pthread.h> and its value shall be distinct from any other value returned by pthread_barrier_wait().

and

the pthread_barrier_wait() function shall return PTHREAD_BARRIER_SERIAL_THREAD for a single (arbitrary) thread synchronized at the barrier and zero for each of the other threads.

So shouldn't the value be something other than 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh... yeah. This is what I get for pushing a feature without a test, I guess. Will fix. I also see I misspelled the name of the symbol in the commit message (though it looks correct here).

@nashif
Copy link
Member

nashif commented Jan 17, 2019

@andyross can you please update this

@ghost
Copy link

ghost commented Mar 1, 2019

This is patched in #14003. Closing as a duplicate fix.

@ghost ghost closed this Mar 1, 2019
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants