Skip to content

Broken mutex #59

@lecopzer

Description

@lecopzer

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions