From e135573acc348649e767ca67a1ec189fe4e0fcda Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 14 Jul 2012 19:30:31 +0000 Subject: Fix STM32 F2/F4 SDIO clocking; Clean-up files in sched/ directory git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4940 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/sched/pthread_mutexlock.c | 64 ++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-) (limited to 'nuttx/sched/pthread_mutexlock.c') diff --git a/nuttx/sched/pthread_mutexlock.c b/nuttx/sched/pthread_mutexlock.c index a56fd9d71..7681d771a 100644 --- a/nuttx/sched/pthread_mutexlock.c +++ b/nuttx/sched/pthread_mutexlock.c @@ -2,7 +2,7 @@ * sched/pthread_mutexlock.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -72,35 +72,38 @@ ****************************************************************************/ /**************************************************************************** - * Function: pthread_mutex_lock + * Name: pthread_mutex_lock * * Description: - * The mutex object referenced by mutex is locked by calling pthread_mutex_lock(). - * If the mutex is already locked, the calling thread blocks until the mutex - * becomes available. This operation returns with the mutex object referenced - * by mutex in the locked state with the calling thread as its owner. + * The mutex object referenced by mutex is locked by calling + * pthread_mutex_lock(). If the mutex is already locked, the calling thread + * blocks until the mutex becomes available. This operation returns with the + * mutex object referenced by mutex in the locked state with the calling + * thread as its owner. * - * If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not provided. - * Attempting to relock the mutex causes deadlock. If a thread attempts to unlock - * a mutex that it has not locked or a mutex which is unlocked, undefined behavior - * results. + * If the mutex type is PTHREAD_MUTEX_NORMAL, deadlock detection is not + * provided. Attempting to relock the mutex causes deadlock. If a thread + * attempts to unlock a mutex that it has not locked or a mutex which is + * unlocked, undefined behavior results. * - * If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is provided. - * If a thread attempts to relock a mutex that it has already locked, an error - * will be returned. If a thread attempts to unlock a mutex that it has not - * locked or a mutex which is unlocked, an error will be returned. + * If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error checking is + * provided. If a thread attempts to relock a mutex that it has already + * locked, an error will be returned. If a thread attempts to unlock a + * mutex that it has not locked or a mutex which is unlocked, an error will + * be returned. * - * If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains the concept - * of a lock count. When a thread successfully acquires a mutex for the first time, - * the lock count is set to one. Every time a thread relocks this mutex, the lock count - * is incremented by one. Each time the thread unlocks the mutex, the lock count is - * decremented by one. When the lock count reaches zero, the mutex becomes available - * for other threads to acquire. If a thread attempts to unlock a mutex that it has - * not locked or a mutex which is unlocked, an error will be returned. + * If the mutex type is PTHREAD_MUTEX_RECURSIVE, then the mutex maintains + * the concept of a lock count. When a thread successfully acquires a mutex + * for the first time, the lock count is set to one. Every time a thread + * relocks this mutex, the lock count is incremented by one. Each time the + * thread unlocks the mutex, the lock count is decremented by one. When the + * lock count reaches zero, the mutex becomes available for other threads to + * acquire. If a thread attempts to unlock a mutex that it has not locked or + * a mutex which is unlocked, an error will be returned. * - * If a signal is delivered to a thread waiting for a mutex, upon return from - * the signal handler the thread resumes waiting for the mutex as if it was - * not interrupted. + * If a signal is delivered to a thread waiting for a mutex, upon return + * from the signal handler the thread resumes waiting for the mutex as if + * it was not interrupted. * * Parameters: * mutex - A reference to the mutex to be locked. @@ -141,16 +144,16 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex) #ifdef CONFIG_MUTEX_TYPES if (mutex->type == PTHREAD_MUTEX_RECURSIVE) { - /* Yes... just increment the number of locks held and return success */ - - mutex->nlocks++; + /* Yes... just increment the number of locks held and return success */ + + mutex->nlocks++; } else #endif { - /* No, then we would deadlock... return an error (default behavior - * is like PTHREAD_MUTEX_ERRORCHECK) - */ + /* No, then we would deadlock... return an error (default behavior + * is like PTHREAD_MUTEX_ERRORCHECK) + */ sdbg("Returning EDEADLK\n"); ret = EDEADLK; @@ -174,6 +177,7 @@ int pthread_mutex_lock(FAR pthread_mutex_t *mutex) #endif } } + sched_unlock(); } -- cgit v1.2.3