Priority macros

This commit is contained in:
NIIBE Yutaka
2013-06-04 13:16:20 +09:00
parent 7a09ac9a10
commit ba594d5eae
3 changed files with 23 additions and 6 deletions

View File

@@ -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>

View File

@@ -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;
}

View File

@@ -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