Commit 449e8b4
authored
🐛 Refactor task_notify_when_deleting to support task_to_notify dying before target_task (purduesigbots#100)
#### Summary:
- Increments `configNUM_THREAD_LOCAL_STORAGE_POINTERS` again
- Adds another linked list to thread local storage that will keep track of the tasks to whose death events `task_to_notify` is subscribed
- When a task dies, the `task_delete_hook` now iterates through the task's list of subscriptions and removes references to itself from the subscriptions' lists of subscribers
#### Motivation:
Previously, the case in which `task_to_notify` dies before `target_task` was undefined behavior, because `target_task` would attempt to notify `task_to_notify` even if it's already been cleaned up. The naive solution of checking the `task_to_notify`'s state directly would not have worked because in certain cases (as with the competition tasks), the TCB can be reused.
More information regarding the motivation behind this change can be found at purduesigbots#86, OkapiLib/OkapiLib#249, and OkapiLib/OkapiLib#321
##### References (optional):
Closes purduesigbots#86
#### Test Plan:
- [x] execute test plan in src/tests/task_notify_when_deleting.c (regression test)
(the following are adapted from purduesigbots#100 (comment). thanks @Octogonapus)
- [x] delete `task_to_notify` and then delete `target_task`, verify nothing goes horrendously wrong
- [x] repeat previous test with OkapiLib where an internal task is the `task_to_notify`
#### Commits:
* begin task_notify_when_deleting refactor
* add nullcheck
needed to check whether subscriptions_list is null in
unsubscribe_hook_cb to handle the "normal operation" case, where
target_task dies before task_to_notify
* delete subscriptions list anyway
* look for correct task in subscriptions_ll
* mutex guard task_notify_when_deleting functions, cleanup includes
* stick with one method of initializing mutex
* Revert "stick with one method of initializing mutex"
This reverts commit 154b969.
* stick with the other method of initializing mutex1 parent ad0f87c commit 449e8b4
File tree
4 files changed
+73
-11
lines changed- include
- pros
- rtos
- src
- rtos
- system
4 files changed
+73
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | 63 | | |
66 | 64 | | |
67 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
144 | | - | |
| 144 | + | |
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
3 | 9 | | |
4 | 10 | | |
5 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
6 | 15 | | |
7 | | - | |
| 16 | + | |
| 17 | + | |
8 | 18 | | |
9 | 19 | | |
10 | 20 | | |
| |||
36 | 46 | | |
37 | 47 | | |
38 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
39 | 53 | | |
40 | 54 | | |
41 | 55 | | |
42 | 56 | | |
43 | 57 | | |
44 | | - | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
48 | 63 | | |
49 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
50 | 91 | | |
51 | 92 | | |
52 | | - | |
| 93 | + | |
53 | 94 | | |
54 | 95 | | |
55 | 96 | | |
| |||
72 | 113 | | |
73 | 114 | | |
74 | 115 | | |
| 116 | + | |
75 | 117 | | |
76 | 118 | | |
77 | 119 | | |
| |||
93 | 135 | | |
94 | 136 | | |
95 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
96 | 147 | | |
97 | 148 | | |
98 | 149 | | |
| |||
103 | 154 | | |
104 | 155 | | |
105 | 156 | | |
106 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
107 | 167 | | |
108 | 168 | | |
109 | 169 | | |
110 | | - | |
| 170 | + | |
111 | 171 | | |
| 172 | + | |
112 | 173 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
0 commit comments