void pthread_destroyjoin(FAR struct task_group_s *group, FAR struct join_s *pjoin);
FAR struct join_s *pthread_findjoininfo(FAR struct task_group_s *group, pid_t pid);
void pthread_release(FAR struct task_group_s *group);
-int pthread_takesemaphore(sem_t *sem, bool intr);
+int pthread_sem_take(sem_t *sem, bool intr);
#ifdef CONFIG_PTHREAD_MUTEX_UNSAFE
int pthread_sem_trytake(sem_t *sem);
#endif
-int pthread_givesemaphore(sem_t *sem);
+int pthread_sem_give(sem_t *sem);
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
int pthread_mutex_take(FAR struct pthread_mutex_s *mutex, bool intr);
int pthread_mutex_give(FAR struct pthread_mutex_s *mutex);
void pthread_mutex_inconsistent(FAR struct pthread_tcb_s *tcb);
#else
-#define pthread_mutex_take(m,i) pthread_takesemaphore(&(m)->sem,(i))
+#define pthread_mutex_take(m,i) pthread_sem_take(&(m)->sem,(i))
#define pthread_mutex_trytake(m) pthread_sem_trytake(&(m)->sem)
-#define pthread_mutex_give(m) pthread_givesemaphore(&(m)->sem)
+#define pthread_mutex_give(m) pthread_sem_give(&(m)->sem)
#endif
#if defined(CONFIG_CANCELLATION_POINTS) && !defined(CONFIG_PTHREAD_MUTEX_UNSAFE)
*/
do {
- status = pthread_givesemaphore(&pjoin->exit_sem);
+ status = pthread_sem_give(&pjoin->exit_sem);
if (status == OK) {
status = sem_getvalue(&pjoin->exit_sem, &ntasks_waiting);
}
* value.
*/
- (void)pthread_takesemaphore(&pjoin->data_sem, false);
+ (void)pthread_sem_take(&pjoin->data_sem, false);
return true;
}
/* First, find thread's structure in the private data set. */
- (void)pthread_takesemaphore(&group->tg_joinsem, false);
+ (void)pthread_sem_take(&group->tg_joinsem, false);
pjoin = pthread_findjoininfo(group, pid);
if (!pjoin) {
sdbg("Could not find join info, pid=%d\n", pid);
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
return ERROR;
} else {
bool waiters;
* to call pthread_destroyjoin.
*/
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
}
return OK;
* Only the highest priority waiting thread will get to execute
*/
- ret = pthread_givesemaphore((sem_t *)&cond->sem);
+ ret = pthread_sem_give((sem_t *)&cond->sem);
/* Increment the semaphore count (as was done by the
* above post).
svdbg("sval=%d\n", sval);
if (sval < 0) {
svdbg("Signalling...\n");
- ret = pthread_givesemaphore((sem_t *)&cond->sem);
+ ret = pthread_sem_give((sem_t *)&cond->sem);
}
}
}
/* Take the semaphore */
- status = pthread_takesemaphore((FAR sem_t *)&cond->sem, false);
+ status = pthread_sem_take((FAR sem_t *)&cond->sem, false);
if (ret == OK) {
/* Report the first failure that occurs */
/* Sucessfully spawned, add the pjoin to our data set. */
- (void)pthread_takesemaphore(&group->tg_joinsem, false);
+ (void)pthread_sem_take(&group->tg_joinsem, false);
pthread_addjoininfo(group, pjoin);
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
/* Report to the spawner that we successfully started. */
pjoin->started = true;
- (void)pthread_givesemaphore(&pjoin->data_sem);
+ (void)pthread_sem_give(&pjoin->data_sem);
/* Pass control to the thread entry point. In the kernel build this has to
* be handled differently if we are starting a user-space pthread; we have
* its join structure.
*/
- (void)pthread_takesemaphore(&pjoin->data_sem, false);
+ (void)pthread_sem_take(&pjoin->data_sem, false);
/* Return the thread information to the caller */
/* Find the entry associated with this pthread. */
- (void)pthread_takesemaphore(&group->tg_joinsem, false);
+ (void)pthread_sem_take(&group->tg_joinsem, false);
pjoin = pthread_findjoininfo(group, (pid_t)thread);
if (!pjoin) {
sdbg("Could not find thread entry\n");
ret = OK;
}
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
svdbg("Returning %d\n", ret);
trace_end(TTRACE_TAG_TASK);
}
/****************************************************************************
- * Name: pthread_takesemaphore and pthread_givesemaphore
+ * Name: pthread_sem_take, pthread_sem_trytake, and
+ * pthread_sem_give
*
* Description:
* Support managed access to the private data sets.
*
+ * REVISIT : These functions really do nothing more than match the return
+ * value of the semaphore functions (0 or -1 with errno set) to the
+ * return value of more pthread functions (0 or errno). A better solution
+ * would be to use an internal version of the semaphore functions that
+ * return the error value in the correct form.
+ *
* Parameters:
* sem - The semaphore to lock or unlock
* intr - false: ignore EINTR errors when locking; true tread EINTR as
*
****************************************************************************/
-int pthread_takesemaphore(sem_t *sem, bool intr)
+int pthread_sem_take(sem_t *sem, bool intr)
{
- trace_begin(TTRACE_TAG_IPC, "pthread_takesemaphore");
+ trace_begin(TTRACE_TAG_IPC, "pthread_sem_take");
/* Verify input parameters */
DEBUGASSERT(sem != NULL);
}
#endif
-int pthread_givesemaphore(sem_t *sem)
+int pthread_sem_give(sem_t *sem)
{
/* Verify input parameters */
* because it will also attempt to get this semaphore.
*/
- (void)pthread_takesemaphore(&group->tg_joinsem, false);
+ (void)pthread_sem_take(&group->tg_joinsem, false);
/* Find the join information associated with this thread.
* This can fail for one of three reasons: (1) There is no
ret = EINVAL;
}
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
} else {
/* We found the join info structure. Increment for the reference
* to the join structure that we have. This will keep things
* semaphore.
*/
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
/* Take the thread's thread exit semaphore. We will sleep here
* until the thread exits. We need to exercise caution because
* pthread to exit.
*/
- (void)pthread_takesemaphore(&pjoin->exit_sem, false);
+ (void)pthread_sem_take(&pjoin->exit_sem, false);
/* The thread has exited! Get the thread exit value */
* will know that we have received the data.
*/
- (void)pthread_givesemaphore(&pjoin->data_sem);
+ (void)pthread_sem_give(&pjoin->data_sem);
/* Retake the join semaphore, we need to hold this when
* pthread_destroyjoin is called.
*/
- (void)pthread_takesemaphore(&group->tg_joinsem, false);
+ (void)pthread_sem_take(&group->tg_joinsem, false);
}
/* Pre-emption is okay now. The logic still cannot be re-entered
(void)pthread_destroyjoin(group, pjoin);
}
- (void)pthread_givesemaphore(&group->tg_joinsem);
+ (void)pthread_sem_give(&group->tg_joinsem);
ret = OK;
}
if ((mutex->flags & _PTHREAD_MFLAGS_INCONSISTENT) != 0) {
ret = EOWNERDEAD;
} else {
- /* Take semaphore underlying the mutex. pthread_takesemaphore
+ /* Take semaphore underlying the mutex. pthread_sem_take
* returns zero on success and a positive errno value on failure.
*/
- ret = pthread_takesemaphore(&mutex->sem, intr);
+ ret = pthread_sem_take(&mutex->sem, intr);
if (ret == OK) {
/* Check if the holder of the mutex has terminated without
* releasing. In that case, the state of the mutex is
/* Now release the underlying semaphore */
- ret = pthread_givesemaphore(&mutex->sem);
+ ret = pthread_sem_give(&mutex->sem);
}
return ret;
/* Mark the mutex as INCONSISTENT and wake up any waiting thread */
mutex->flags |= _PTHREAD_MFLAGS_INCONSISTENT;
- (void)pthread_givesemaphore(&mutex->sem);
+ (void)pthread_sem_give(&mutex->sem);
}
sched_unlock();