Skip to content

Commit 9cd8ff5

Browse files
hujun260xiaoxiang781216
authored andcommitted
pthread: sched_lock should replace with enter_critical_secion
sched_lock cannot lock threads from other CPUs, use enter_critical_section Signed-off-by: hujun5 <hujun5@xiaomi.com>
1 parent 447a0bc commit 9cd8ff5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sched/pthread/pthread_mutexunlock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static inline bool pthread_mutex_islocked(FAR struct pthread_mutex_s *mutex)
101101
int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
102102
{
103103
int ret = EPERM;
104+
irqstate_t flags;
104105

105106
sinfo("mutex=%p\n", mutex);
106107
DEBUGASSERT(mutex != NULL);
@@ -113,7 +114,7 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
113114
* This all needs to be one atomic action.
114115
*/
115116

116-
sched_lock();
117+
flags = enter_critical_section();
117118

118119
/* The unlock operation is only performed if the mutex is actually locked.
119120
* EPERM *must* be returned if the mutex type is PTHREAD_MUTEX_ERRORCHECK
@@ -223,7 +224,7 @@ int pthread_mutex_unlock(FAR pthread_mutex_t *mutex)
223224
}
224225
}
225226

226-
sched_unlock();
227+
leave_critical_section(flags);
227228
sinfo("Returning %d\n", ret);
228229
return ret;
229230
}

0 commit comments

Comments
 (0)