Skip to content

Commit

Permalink
pthread_cleanup: rm sched_[un]lock
Browse files Browse the repository at this point in the history
Since TLS is only used within a single thread and requires no additional protection.

Signed-off-by: hujun5 <[email protected]>
  • Loading branch information
hujun260 committed Sep 19, 2023
1 parent 89e409a commit dc76fae
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions libs/libc/pthread/pthread_cleanup.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@
* Returned Value:
* None
*
* Assumptions:
* The scheduler is locked.
*
****************************************************************************/

static void pthread_cleanup_pop_tls(FAR struct tls_info_s *tls, int execute)
Expand Down Expand Up @@ -122,14 +119,7 @@ void pthread_cleanup_pop(int execute)

DEBUGASSERT(tls != NULL);

/* sched_lock() should provide sufficient protection. We only need to
* have this TCB stationary; the pthread cleanup stack should never be
* modified by interrupt level logic.
*/

sched_lock();
pthread_cleanup_pop_tls(tls, execute);
sched_unlock();
}

void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
Expand All @@ -139,12 +129,6 @@ void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
DEBUGASSERT(tls != NULL);
DEBUGASSERT(tls->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE);

/* sched_lock() should provide sufficient protection. We only need to
* have this TCB stationary; the pthread cleanup stack should never be
* modified by interrupt level logic.
*/

sched_lock();
if (tls->tos < CONFIG_PTHREAD_CLEANUP_STACKSIZE)
{
unsigned int ndx = tls->tos;
Expand All @@ -153,8 +137,6 @@ void pthread_cleanup_push(pthread_cleanup_t routine, FAR void *arg)
tls->stack[ndx].pc_cleaner = routine;
tls->stack[ndx].pc_arg = arg;
}

sched_unlock();
}

/****************************************************************************
Expand All @@ -177,13 +159,10 @@ void pthread_cleanup_popall(FAR struct tls_info_s *tls)
{
DEBUGASSERT(tls != NULL);

sched_lock();
while (tls->tos > 0)
{
pthread_cleanup_pop_tls(tls, 1);
}

sched_unlock();
}

#endif /* defined(CONFIG_PTHREAD_CLEANUP_STACKSIZE) && CONFIG_PTHREAD_CLEANUP_STACKSIZE > 0 */

0 comments on commit dc76fae

Please sign in to comment.