pkarashchenko commented on a change in pull request #5171: URL: https://github.com/apache/incubator-nuttx/pull/5171#discussion_r778982536
########## File path: sched/semaphore/sem_holder.c ########## @@ -187,35 +194,36 @@ nxsem_findorallocateholder(sem_t *sem, FAR struct tcb_s *htcb) static inline void nxsem_freeholder(sem_t *sem, FAR struct semholder_s *pholder) { -#if CONFIG_SEM_PREALLOCHOLDERS > 0 - FAR struct semholder_s *curr; - FAR struct semholder_s *prev; -#endif + FAR struct semholder_s **curr; Review comment: ```suggestion struct semholder_s * FAR *curr; ``` ########## File path: include/semaphore.h ########## @@ -58,19 +58,23 @@ #ifdef CONFIG_PRIORITY_INHERITANCE struct tcb_s; /* Forward reference */ +struct sem_s; + struct semholder_s { #if CONFIG_SEM_PREALLOCHOLDERS > 0 - struct semholder_s *flink; /* Implements singly linked list */ + struct semholder_s *flink; /* List of semphore's holder */ Review comment: ```suggestion FAR struct semholder_s *flink; /* List of semphore's holder */ ``` ########## File path: include/semaphore.h ########## @@ -58,19 +58,23 @@ #ifdef CONFIG_PRIORITY_INHERITANCE struct tcb_s; /* Forward reference */ +struct sem_s; + struct semholder_s { #if CONFIG_SEM_PREALLOCHOLDERS > 0 - struct semholder_s *flink; /* Implements singly linked list */ + struct semholder_s *flink; /* List of semphore's holder */ #endif - FAR struct tcb_s *htcb; /* Holder TCB */ + struct semholder_s *tlink; /* List of task held semphores */ Review comment: ```suggestion FAR struct semholder_s *tlink; /* List of task held semphores */ ``` ########## File path: sched/semaphore/sem_holder.c ########## @@ -1200,4 +1211,31 @@ int nxsem_nfreeholders(void) } #endif +/**************************************************************************** + * Name: nxsem_release_all + * + * Description: + * Release all semphore holders for the task. + * + * Input Parameters: + * stcb - TCB of the task + * + * Returned Value: + * None + * + * Assumptions: + * + ****************************************************************************/ + +void nxsem_release_all(FAR struct tcb_s *htcb) +{ + while (htcb->holdsem != NULL) + { + FAR struct semholder_s *pholder = htcb->holdsem; + FAR sem_t *sem = pholder->sem; + + nxsem_freeholder(sem, pholder); + } +} Review comment: Minor ```suggestion void nxsem_release_all(FAR struct tcb_s *htcb) { FAR struct semholder_s *pholder; while ((pholder = htcb->holdsem) != NULL) { FAR sem_t *sem = pholder->sem; nxsem_freeholder(sem, pholder); } } ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org