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

Broken mutex #59

Open
lecopzer opened this issue Aug 22, 2018 · 0 comments
Open

Broken mutex #59

lecopzer opened this issue Aug 22, 2018 · 0 comments

Comments

@lecopzer
Copy link
Contributor

HI,
https://github.com/PikoRT/pikoRT/blob/master/kernel/mutex.c#L14

int sys_pthread_mutex_lock(kernel_mutex_t *mutex)
{
    mutex->val++;
    if (!mutex->val)
        return 0;

I'm pretty sure such code is not mutual exclusion.
It better to implement cmpxchg by ldrex or ldxr

Also, the tests for mutext_* are not test for mutual exclusion at all, they only test for the functions finish execution or not.

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

No branches or pull requests

1 participant