| 72 | ****************************************************************************/ |
| 73 | |
| 74 | static void exec_swap(FAR struct tcb_s *ptcb, FAR struct tcb_s *chtcb) |
| 75 | { |
| 76 | int pndx; |
| 77 | int chndx; |
| 78 | pid_t pid; |
| 79 | irqstate_t flags; |
| 80 | #ifdef CONFIG_SCHED_HAVE_PARENT |
| 81 | # ifdef CONFIG_SCHED_CHILD_STATUS |
| 82 | FAR struct child_status_s *tg_children; |
| 83 | # else |
| 84 | uint16_t tg_nchildren; |
| 85 | # endif |
| 86 | #endif |
| 87 | |
| 88 | DEBUGASSERT(ptcb); |
| 89 | DEBUGASSERT(chtcb); |
| 90 | |
| 91 | flags = enter_critical_section(); |
| 92 | |
| 93 | pndx = PIDHASH(ptcb->pid); |
| 94 | chndx = PIDHASH(chtcb->pid); |
| 95 | |
| 96 | DEBUGASSERT(g_pidhash[pndx]); |
| 97 | DEBUGASSERT(g_pidhash[chndx]); |
| 98 | |
| 99 | /* Exchange g_pidhash index */ |
| 100 | |
| 101 | g_pidhash[pndx] = chtcb; |
| 102 | g_pidhash[chndx] = ptcb; |
| 103 | |
| 104 | /* Exchange pid */ |
| 105 | |
| 106 | pid = chtcb->pid; |
| 107 | chtcb->pid = ptcb->pid; |
| 108 | ptcb->pid = pid; |
| 109 | |
| 110 | /* Exchange group info. This will reverse parent-child relationship */ |
| 111 | |
| 112 | pid = chtcb->group->tg_pid; |
| 113 | chtcb->group->tg_pid = ptcb->group->tg_pid; |
| 114 | ptcb->group->tg_pid = pid; |
| 115 | |
| 116 | pid = chtcb->group->tg_ppid; |
| 117 | chtcb->group->tg_ppid = ptcb->group->tg_ppid; |
| 118 | ptcb->group->tg_ppid = pid; |
| 119 | |
| 120 | #ifdef CONFIG_SCHED_HAVE_PARENT |
| 121 | # ifdef CONFIG_SCHED_CHILD_STATUS |
| 122 | tg_children = chtcb->group->tg_children; |
| 123 | chtcb->group->tg_children = ptcb->group->tg_children; |
| 124 | ptcb->group->tg_children = tg_children; |
| 125 | # else |
| 126 | tg_nchildren = chtcb->group->tg_nchildren; |
| 127 | chtcb->group->tg_nchildren = ptcb->group->tg_nchildren; |
| 128 | ptcb->group->tg_nchildren = tg_nchildren; |
| 129 | # endif |
| 130 | #endif |
| 131 |
no test coverage detected