diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/alpine_cdc.c | 8 | ||||
-rw-r--r-- | apps/plugins/battery_bench.c | 18 |
2 files changed, 9 insertions, 17 deletions
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index 65108680c6..9c1bc8bd0b 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c | |||
@@ -202,7 +202,6 @@ struct | |||
202 | /* communication to the worker thread */ | 202 | /* communication to the worker thread */ |
203 | struct | 203 | struct |
204 | { | 204 | { |
205 | struct thread_entry *id; /* Pointer of the thread */ | ||
206 | bool foreground; /* set as long as we're owning the UI */ | 205 | bool foreground; /* set as long as we're owning the UI */ |
207 | bool exiting; /* signal to the thread that we want to exit */ | 206 | bool exiting; /* signal to the thread that we want to exit */ |
208 | bool ended; /* response from the thread, that is has exited */ | 207 | bool ended; /* response from the thread, that is has exited */ |
@@ -1117,8 +1116,7 @@ void thread(void) | |||
1117 | } while (!gTread.exiting); | 1116 | } while (!gTread.exiting); |
1118 | 1117 | ||
1119 | gTread.ended = true; /* acknowledge the exit */ | 1118 | gTread.ended = true; /* acknowledge the exit */ |
1120 | rb->remove_thread(gTread.id); /* commit suicide */ | 1119 | rb->remove_thread(NULL); /* commit suicide */ |
1121 | rb->yield(); /* pass control to other threads, we won't return */ | ||
1122 | } | 1120 | } |
1123 | 1121 | ||
1124 | /* callback to end the TSR plugin, called before a new one gets loaded */ | 1122 | /* callback to end the TSR plugin, called before a new one gets loaded */ |
@@ -1172,8 +1170,8 @@ int main(void* parameter) | |||
1172 | 1170 | ||
1173 | rb->memset(&gTread, 0, sizeof(gTread)); | 1171 | rb->memset(&gTread, 0, sizeof(gTread)); |
1174 | gTread.foreground = true; | 1172 | gTread.foreground = true; |
1175 | gTread.id = rb->create_thread(thread, stack, stacksize, "CDC" | 1173 | rb->create_thread(thread, stack, stacksize, "CDC" |
1176 | IF_PRIO(, PRIORITY_BACKGROUND)); | 1174 | IF_PRIO(, PRIORITY_BACKGROUND)); |
1177 | 1175 | ||
1178 | #ifdef DEBUG | 1176 | #ifdef DEBUG |
1179 | do | 1177 | do |
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index bf0c2f32dd..4f1016b7eb 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c | |||
@@ -111,11 +111,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
111 | return main(); | 111 | return main(); |
112 | } | 112 | } |
113 | 113 | ||
114 | struct | 114 | bool thread_stopped = false; |
115 | { | ||
116 | struct thread_entry *id; | ||
117 | bool ended; | ||
118 | } s_thread; | ||
119 | 115 | ||
120 | /* Struct for battery information */ | 116 | /* Struct for battery information */ |
121 | struct batt_info | 117 | struct batt_info |
@@ -142,7 +138,7 @@ bool exit_tsr(bool reenter) | |||
142 | if (exit) | 138 | if (exit) |
143 | { | 139 | { |
144 | rb->queue_post(&thread_q, EV_EXIT, 0); | 140 | rb->queue_post(&thread_q, EV_EXIT, 0); |
145 | while (!s_thread.ended) | 141 | while (!thread_stopped) |
146 | rb->yield(); | 142 | rb->yield(); |
147 | /* remove the thread's queue from the broadcast list */ | 143 | /* remove the thread's queue from the broadcast list */ |
148 | rb->queue_delete(&thread_q); | 144 | rb->queue_delete(&thread_q); |
@@ -330,9 +326,8 @@ void thread(void) | |||
330 | #else | 326 | #else |
331 | "bench exit"); | 327 | "bench exit"); |
332 | #endif | 328 | #endif |
333 | s_thread.ended = true; | 329 | thread_stopped = true; |
334 | rb->remove_thread(s_thread.id); | 330 | rb->remove_thread(NULL); /* Suicide. Never returns. */ |
335 | rb->yield(); /* exit the thread, this yield() won't return */ | ||
336 | } | 331 | } |
337 | 332 | ||
338 | rb->queue_wait_w_tmo(&thread_q, &ev, sleep_time); | 333 | rb->queue_wait_w_tmo(&thread_q, &ev, sleep_time); |
@@ -482,10 +477,9 @@ int main(void) | |||
482 | } | 477 | } |
483 | 478 | ||
484 | rb->queue_init(&thread_q, true); /* put the thread's queue in the bcast list */ | 479 | rb->queue_init(&thread_q, true); /* put the thread's queue in the bcast list */ |
485 | rb->memset(&s_thread, 0, sizeof(s_thread)); /* zero the struct */ | 480 | if(rb->create_thread(thread, thread_stack, |
486 | if((s_thread.id = rb->create_thread(thread, thread_stack, | ||
487 | sizeof(thread_stack), "Battery Benchmark" | 481 | sizeof(thread_stack), "Battery Benchmark" |
488 | IF_PRIO(, PRIORITY_BACKGROUND))) == NULL) | 482 | IF_PRIO(, PRIORITY_BACKGROUND)) == NULL) |
489 | { | 483 | { |
490 | rb->splash(HZ,true,"Cannot create thread!"); | 484 | rb->splash(HZ,true,"Cannot create thread!"); |
491 | return PLUGIN_ERROR; | 485 | return PLUGIN_ERROR; |