From 0d460b28c769fd2a1d2efb85f11edd4189fb5713 Mon Sep 17 00:00:00 2001 From: zilio nicolas Date: Fri, 11 Sep 2015 15:36:17 +0200 Subject: reviewd old tasks comments for doxygen and update --- pcilib/lock.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'pcilib/lock.c') diff --git a/pcilib/lock.c b/pcilib/lock.c index 03a2377..25e12a5 100644 --- a/pcilib/lock.c +++ b/pcilib/lock.c @@ -18,22 +18,21 @@ #include "lock.h" #include "pci.h" - +/** + * structure to define a lock + */ struct pcilib_lock_s { - pthread_mutex_t mutex; - pcilib_lock_flags_t flags; + pthread_mutex_t mutex; /**< the pthread robust mutex itself*/ + pcilib_lock_flags_t flags; /**mutex); break; case PCILIB_TIMEOUT_IMMEDIATE: + /* the function returns immediatly if it can't acquire the lock*/ err = pthread_mutex_trylock(&lock->mutex); break; default: + /* the process will be hold till it can acquire the lock and timeout is not reached*/ clock_gettime(CLOCK_REALTIME, &tm); tm.tv_nsec += 1000 * (timeout%1000000); if (tm.tv_nsec < 1000000000) @@ -171,6 +169,7 @@ int pcilib_lock_custom(pcilib_lock_t *lock, pcilib_lock_flags_t flags, pcilib_ti switch (err) { case EOWNERDEAD: + /*in the case an application with a lock acquired crashes, this lock becomes inconsistent. we have so to make it consistent again to use it again.*/ err = pthread_mutex_consistent(&lock->mutex); if (err) { pcilib_error("Failed to mark mutex as consistent, errno %i", err); @@ -195,9 +194,6 @@ int pcilib_try_lock(pcilib_lock_t* lock) { return pcilib_lock_custom(lock, PCILIB_LOCK_FLAGS_DEFAULT, PCILIB_TIMEOUT_IMMEDIATE); } -/** - * this function will unlock the semaphore pointed by lock_ctx. - */ void pcilib_unlock(pcilib_lock_t *lock) { int err; -- cgit v1.2.3