summaryrefslogtreecommitdiff
path: root/nuttx/sched/pthread_mutexlock.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-14 19:30:31 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-14 19:30:31 +0000
commite135573acc348649e767ca67a1ec189fe4e0fcda (patch)
treeb34f7d2914cba8aeb9311c5bae3771af40054640 /nuttx/sched/pthread_mutexlock.c
parentd76fa866ad009d65396acf1aa08fcffd3b4b041e (diff)
downloadpx4-nuttx-e135573acc348649e767ca67a1ec189fe4e0fcda.tar.gz
px4-nuttx-e135573acc348649e767ca67a1ec189fe4e0fcda.tar.bz2
px4-nuttx-e135573acc348649e767ca67a1ec189fe4e0fcda.zip
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
Diffstat (limited to 'nuttx/sched/pthread_mutexlock.c')
-rw-r--r--nuttx/sched/pthread_mutexlock.c64
1 files changed, 34 insertions, 30 deletions
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 <spudmonkey@racsa.co.cr>
+ * Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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();
}