mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
semphore: release all semphores' holder that the task held when exit
Add a list in TCB to track all semphores the task held, so we can release all holders when exit, so nxsched_verify_tcb is unnecessary. Signed-off-by: Zeng Zhaoxiu <walker.zeng@transtekcorp.com>
This commit is contained in:
@@ -610,6 +610,7 @@ struct tcb_s
|
||||
uint8_t pend_reprios[CONFIG_SEM_NNESTPRIO];
|
||||
#endif
|
||||
uint8_t base_priority; /* "Normal" priority of the thread */
|
||||
FAR struct semholder_s *holdsem; /* List of held semaphores */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SMP
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
{(c), (f), NULL} /* semcount, flags, hhead */
|
||||
# else
|
||||
# define NXSEM_INITIALIZER(c, f) \
|
||||
{(c), (f), {{NULL, 0}, {NULL, 0}}} /* semcount, flags, holder[2] */
|
||||
{(c), (f), {SEMHOLDER_INITIALIZER, SEMHOLDER_INITIALIZER}} /* semcount, flags, holder[2] */
|
||||
# endif
|
||||
#else /* CONFIG_PRIORITY_INHERITANCE */
|
||||
# define NXSEM_INITIALIZER(c, f) \
|
||||
|
||||
+24
-5
@@ -58,19 +58,38 @@
|
||||
|
||||
#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 */
|
||||
FAR struct semholder_s *flink; /* List of semaphore's holder */
|
||||
#endif
|
||||
FAR struct tcb_s *htcb; /* Holder TCB */
|
||||
int16_t counts; /* Number of counts owned by this holder */
|
||||
FAR struct semholder_s *tlink; /* List of task held semaphores */
|
||||
FAR struct sem_s *sem; /* Ths corresponding semaphore */
|
||||
FAR struct tcb_s *htcb; /* Ths corresponding TCB */
|
||||
int16_t counts; /* Number of counts owned by this holder */
|
||||
};
|
||||
|
||||
#if CONFIG_SEM_PREALLOCHOLDERS > 0
|
||||
# define SEMHOLDER_INITIALIZER {NULL, NULL, 0}
|
||||
# define SEMHOLDER_INITIALIZER {NULL, NULL, NULL, NULL, 0}
|
||||
# define INITIALIZE_SEMHOLDER(h) \
|
||||
do { \
|
||||
(h)->flink = NULL; \
|
||||
(h)->tlink = NULL; \
|
||||
(h)->sem = NULL; \
|
||||
(h)->htcb = NULL; \
|
||||
(h)->counts = 0; \
|
||||
} while (0)
|
||||
#else
|
||||
# define SEMHOLDER_INITIALIZER {NULL, 0}
|
||||
# define SEMHOLDER_INITIALIZER {NULL, NULL, NULL, 0}
|
||||
# define INITIALIZE_SEMHOLDER(h) \
|
||||
do { \
|
||||
(h)->tlink = NULL; \
|
||||
(h)->sem = NULL; \
|
||||
(h)->htcb = NULL; \
|
||||
(h)->counts = 0; \
|
||||
} while (0)
|
||||
#endif
|
||||
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user