kernel/binary_manager: Link blink of old head to new head when adding tcb to binary list
When adding tcb to binary list, it is added to a head of list.
So a blink of old head should pointed to new head.
@@ -198,18 +198,25 @@ void binary_manager_add_binlist(FAR struct tcb_s *tcb)
{
int bin_idx;
- if (tcb->group) {
bin_idx = tcb->group->tg_binidx;
+
+ /* A binary index, bin_idx is greater than 0 only if tcb is a thread of user binary.
+ * Add tcb to the binary list for fault recovery in case of threads of user binary.
+ * Otherwise, it is unnecessary for idle or kernel threads. */
if (bin_idx > 0) {
/* Add a tcb to a head of list */
- tcb->bin_blink = NULL;
if (tcb->sched_priority > BM_PRIORITY_MAX) {
+ if (BIN_RTLIST(bin_idx)) {
tcb->bin_flink = BIN_RTLIST(bin_idx);
+ BIN_RTLIST(bin_idx)->bin_blink = tcb;
+ }
BIN_RTLIST(bin_idx) = tcb;
} else {
+ if (BIN_NRTLIST(bin_idx)) {
tcb->bin_flink = BIN_NRTLIST(bin_idx);
- BIN_NRTLIST(bin_idx) = tcb;
+ BIN_NRTLIST(bin_idx)->bin_blink = tcb;
}
+ BIN_NRTLIST(bin_idx) = tcb;
}
}
}
@@ -227,7 +234,6 @@ void binary_manager_remove_binlist(FAR struct tcb_s *tcb)
struct tcb_s *prev;
struct tcb_s *next;
- if (tcb->group) {
bin_idx = tcb->group->tg_binidx;
if (bin_idx > 0) {
/* Remove a tcb from the thread list of binary */
@@ -245,4 +251,3 @@ void binary_manager_remove_binlist(FAR struct tcb_s *tcb)
if (next) next->bin_blink = prev;
}
}
-}
