sem_tickwait(): Add a new, non-standard function to perform timed semaphore waits. It is functionally equialent to the standard sem_timedwait(), but more efficient for use in higher performance device drivers. Requested by Max Neklyudov

This commit is contained in:
Gregory Nutt
2015-08-01 07:30:23 -06:00
parent 5772813d29
commit 2c66e0eb2a
7 changed files with 50 additions and 144 deletions
+22 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* include/nuttx/semaphore.h
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -51,7 +51,7 @@
****************************************************************************/
/****************************************************************************
* Public Data
* Public Type Definitions
****************************************************************************/
#ifdef CONFIG_FS_NAMED_SEMAPHORES
@@ -64,7 +64,6 @@ struct nsem_inode_s
FAR struct inode *ns_inode; /* Containing inode */
sem_t ns_sem; /* The semaphore */
};
#endif
@@ -86,6 +85,26 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sem_tickwait
*
* Description:
* This function is a lighter weight version of sem_timedwait(). It is
* non-standard and intended only for use within the RTOS.
*
* Parameters:
* sem - Semaphore object
* ticks - Ticks to wait until the semaphore is posted. If ticks is
* zero, then this function is equivalent to sem_trywait().
*
* Return Value:
* Zero (OK) is returned on success. A negated errno value is returned on
* failure. -ETIMEDOUT is returned on the timeout condition.
*
****************************************************************************/
int sem_tickwait(FAR sem_t *sem, uint32_t ticks);
#undef EXTERN
#ifdef __cplusplus
}