On Mon, Sep 23, 2013 at 09:13:25AM +0200, Marin Ramesa wrote:
> int atomic_inc(mutex_t mtx)
> {
>       int ret = mtx->value;
>       
>       simple_lock(&(mtx->inc_lock);
>       mtx->value++;
>       simple_unlock(&(mtx->inc_lock));
> 
>       return ret;
> }

Besides, you fetch the value of the mutex outside the critical section.
This really is a beginner mistake, showing that you probably need to
gain experience with concurrency itself first.

-- 
Richard Braun

Reply via email to