kernel: main: Add panic if thread creation fails
Add check for thread creation and panic if it fails.
Change-Id: I1960dc2ba9496b602dad30402150e7035522077d
diff --git a/dev/vib/vibrator.c b/dev/vib/vibrator.c
index 03b7a87..cc47b24 100644
--- a/dev/vib/vibrator.c
+++ b/dev/vib/vibrator.c
@@ -90,6 +90,10 @@
*/
void vib_timed_turn_on(const uint32_t vibrate_time)
{
+#if USE_VIB_THREAD
+ thread_t *thr;
+#endif
+
if(!vib_timeout){
dprintf(CRITICAL,"vibrator already turn on\n");
return;
@@ -101,8 +105,14 @@
timer_set_oneshot(&vib_timer, vibrate_time, vib_timer_func, NULL);
#else
vib_time = (vibrate_time/CHECK_VIB_TIMER_FREQUENCY)+1;
- thread_resume(thread_create("vibrator_thread", &vibrator_thread,
- NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
+ thread_create("vibrator_thread", &vibrator_thread,
+ NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
+ if (!thr)
+ {
+ panic("failed to create vibrator thread\n");
+ }
+ thread_resume(thr);
+
#endif
}
diff --git a/kernel/dpc.c b/kernel/dpc.c
index 184ac31..dd70b96 100644
--- a/kernel/dpc.c
+++ b/kernel/dpc.c
@@ -42,9 +42,16 @@
void dpc_init(void)
{
+ thread_t *thr;
+
event_init(&dpc_event, false, 0);
- thread_resume(thread_create("dpc", &dpc_thread_routine, NULL, DPC_PRIORITY, DEFAULT_STACK_SIZE));
+ thr = thread_create("dpc", &dpc_thread_routine, NULL, DPC_PRIORITY, DEFAULT_STACK_SIZE);
+ if (!thr)
+ {
+ panic("failed to create dpc thread\n");
+ }
+ thread_resume(thr);
}
status_t dpc_queue(dpc_callback cb, void *arg, uint flags)
diff --git a/kernel/main.c b/kernel/main.c
index 95a4339..a40aa7d 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -65,6 +65,8 @@
void kmain(void) __NO_RETURN __EXTERNALLY_VISIBLE;
void kmain(void)
{
+ thread_t *thr;
+
// get us into some sort of thread context
thread_init_early();
@@ -105,7 +107,13 @@
#if (!ENABLE_NANDWRITE)
// create a thread to complete system initialization
dprintf(SPEW, "creating bootstrap completion thread\n");
- thread_resume(thread_create("bootstrap2", &bootstrap2, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));
+ thr = thread_create("bootstrap2", &bootstrap2, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE);
+ if (!thr)
+ {
+ panic("failed to create thread bootstrap2\n");
+ }
+ thread_resume(thr);
+
// enable interrupts
exit_critical_section();