fix mutex_trylock bug
authorweiyu <weiyuluo1232@gmail.com>
Sat, 5 Sep 2020 00:20:23 +0000 (17:20 -0700)
committerweiyu <weiyuluo1232@gmail.com>
Sat, 5 Sep 2020 00:20:23 +0000 (17:20 -0700)
pthread.cc

index e95fb37a3c9b079599b19ca90dd9f00d74fd66b3..e64cd134b91f4b4aebf0723adc78e283154b7c50 100644 (file)
@@ -119,7 +119,7 @@ int pthread_mutex_trylock(pthread_mutex_t *p_mutex) {
 
        ModelExecution *execution = model->get_execution();
        cdsc::snapmutex *m = execution->getMutexMap()->get(p_mutex);
 
        ModelExecution *execution = model->get_execution();
        cdsc::snapmutex *m = execution->getMutexMap()->get(p_mutex);
-       return m->try_lock();
+       return m->try_lock() ? 0 : EBUSY;
 }
 int pthread_mutex_unlock(pthread_mutex_t *p_mutex) {
        ModelExecution *execution = model->get_execution();
 }
 int pthread_mutex_unlock(pthread_mutex_t *p_mutex) {
        ModelExecution *execution = model->get_execution();