summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pcilib/lock.c4
-rw-r--r--pcilib/lock.h7
2 files changed, 11 insertions, 0 deletions
diff --git a/pcilib/lock.c b/pcilib/lock.c
index 13e363a..9045ffa 100644
--- a/pcilib/lock.c
+++ b/pcilib/lock.c
@@ -190,6 +190,10 @@ int pcilib_lock(pcilib_lock_t* lock) {
return pcilib_lock_custom(lock, PCILIB_LOCK_FLAGS_DEFAULT, PCILIB_TIMEOUT_INFINITE);
}
+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.
*/
diff --git a/pcilib/lock.h b/pcilib/lock.h
index 8e1017a..9ffe4cf 100644
--- a/pcilib/lock.h
+++ b/pcilib/lock.h
@@ -87,6 +87,13 @@ int pcilib_lock_custom(pcilib_lock_t* lock, pcilib_lock_flags_t flags, pcilib_ti
int pcilib_lock(pcilib_lock_t* lock);
/**
+ * this function will try to take a lock for the mutex pointed by lock
+ * @param[in] lock the pointer to the mutex
+ */
+int pcilib_try_lock(pcilib_lock_t* lock);
+
+
+/**
* this function will unlock the lock pointed by lock
* @param[in] lock the integer that points to the semaphore
*/