diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-04 13:16:20 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2013-06-04 13:16:20 +0900 |
commit | ba594d5eaebe0885b09f9633b58ae55b1b03b246 (patch) | |
tree | af6f126e7905fc1a298216c0287102af64da4c67 | |
parent | 7a09ac9a10ece38ec11c9d8588f198eea5c422b1 (diff) |
Priority macros
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | chopstx.c | 15 | ||||
-rw-r--r-- | chopstx.h | 13 |
3 files changed, 23 insertions, 6 deletions
@@ -6,6 +6,7 @@ (preempt, chx_timer_expired, chx_handle_intr): Those can be considered holding cpu_sched_lock (by its equal exception priorities), thus no acquiring lock required. + (CHX_PRIO_MAIN): New macro. 2013-06-03 Niibe Yutaka <gniibe@fsij.org> @@ -32,7 +32,14 @@ #include <chopstx.h> /* - * Note: Lower has higher precedence. + * Thread priority: higer has higher precedence. + */ +#if !defined(CHX_PRIO_DEFAULT) +#define CHX_PRIO_MAIN 1 +#endif + +/* + * Exception priority: lower has higher precedence. * * Prio 0x30: svc * --------------------- @@ -635,8 +642,6 @@ static uint32_t *const AIRCR = (uint32_t *const)0xE000ED0C; static uint32_t *const SHPR2 = (uint32_t *const)0xE000ED1C; static uint32_t *const SHPR3 = (uint32_t *const)0xE000ED20; -#define PRIO_DEFAULT 1 - void chx_init (struct chx_thread *tp) { @@ -655,7 +660,7 @@ chx_init (struct chx_thread *tp) tp->state = THREAD_RUNNING; tp->flag_detached = tp->flag_got_cancel = tp->flag_join_req = tp->flag_sched_rr = 0; - tp->prio_orig = tp->prio = PRIO_DEFAULT; + tp->prio_orig = tp->prio = CHX_PRIO_MAIN; tp->v = 0; running = tp; @@ -757,7 +762,7 @@ chx_mutex_unlock (chopstx_mutex_t *mutex) void chopstx_attr_init (chopstx_attr_t *attr) { - attr->prio = PRIO_DEFAULT; + attr->prio = CHX_PRIO_DEFAULT; attr->addr = 0; attr->size = 0; } @@ -91,7 +91,10 @@ void chopstx_release_irq (chopstx_intr_t *intr); void chopstx_intr_wait (chopstx_intr_t *intr); -/* Library provides default as weak reference. User can replace it. */ +/* + * Library provides default implementation as weak reference. + * User can replace it. + */ void chx_fatal (uint32_t err_code) __attribute__((__noreturn__)); void chopstx_join (chopstx_t, void **); @@ -111,3 +114,11 @@ enum { void chopstx_cancel (chopstx_t thd); void chopstx_testcancel (void); + +/* + * User can define this macro (like: -DCHX_PRIO_DEFAULT=3) to specify + * default priority. + */ +#if !defined(CHX_PRIO_DEFAULT) +#define CHX_PRIO_DEFAULT 1 +#endif |