From 0b46ccbae10d5478ca4ad2e188678632d76d2210 Mon Sep 17 00:00:00 2001
From: NIIBE Yutaka <gniibe@fsij.org>
Date: Thu, 6 Jun 2013 14:44:54 +0900
Subject: bug fix for flag_sched_rr

---
 ChangeLog | 1 +
 chopstx.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 234aceb..f951ec6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
 	* entry.c: Include sys.h for clock_init and gpio_init.
 
 	* chopstx.c (PREEMPTION_USEC): Fix the value.
+	(sched): Check tp != NULL to see flag_sched_rr.
 
 2013-06-05  Niibe Yutaka  <gniibe@fsij.org>
 
diff --git a/chopstx.c b/chopstx.c
index 0e394e4..9318a38 100644
--- a/chopstx.c
+++ b/chopstx.c
@@ -357,7 +357,7 @@ sched (void)
   register struct chx_thread *tp asm ("r0");
 
   tp = chx_ready_pop ();
-  if (tp->flag_sched_rr)
+  if (tp && tp->flag_sched_rr)
     {
       chx_spin_lock (&q_timer.lock);
       chx_timer_insert (tp, PREEMPTION_USEC);
-- 
cgit v1.2.3