diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2015-04-18 12:19:43 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2015-04-18 12:23:35 +0900 |
commit | a0f33c1036417c118496d77c98f0f7f1116df5bd (patch) | |
tree | 7a0e4caa7fd91b52d9f37feb8fe96bdca512bf7c | |
parent | 2fb7fb6826454b109f31901e48b2ae452d223ded (diff) |
New: chopstx_main_init
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | chopstx.c | 32 | ||||
-rw-r--r-- | chopstx.h | 2 |
3 files changed, 35 insertions, 5 deletions
@@ -1,3 +1,9 @@ +2015-04-17 Niibe Yutaka <gniibe@fsij.org> + + * chopstx.c (CHX_PRIO_MAIN_INIT): New, removing CHX_PRIO_MAIN. + (chopstx_main_init): New. + (chx_init): Use CHX_PRIO_MAIN_INIT. + 2015-03-17 Niibe Yutaka <gniibe@fsij.org> * VERSION: 0.04a. @@ -34,8 +34,8 @@ /* * Thread priority: higer has higher precedence. */ -#if !defined(CHX_PRIO_MAIN) -#define CHX_PRIO_MAIN 1 +#if !defined(CHX_PRIO_MAIN_INIT) +#define CHX_PRIO_MAIN_INIT 1 #endif #if !defined(CHX_FLAGS_MAIN) #define CHX_FLAGS_MAIN 0 @@ -740,20 +740,42 @@ chx_init (struct chx_thread *tp) tp->flag_got_cancel = tp->flag_join_req = 0; tp->flag_sched_rr = (CHX_FLAGS_MAIN & CHOPSTX_SCHED_RR)? 1 : 0; tp->flag_detached = (CHX_FLAGS_MAIN & CHOPSTX_DETACHED)? 1 : 0; - tp->prio_orig = CHX_PRIO_MAIN; + tp->prio_orig = CHX_PRIO_MAIN_INIT; tp->prio = 0; tp->v = 0; running = tp; - if (CHX_PRIO_MAIN >= CHOPSTX_PRIO_INHIBIT_PREEMPTION) + if (CHX_PRIO_MAIN_INIT >= CHOPSTX_PRIO_INHIBIT_PREEMPTION) chx_cpu_sched_lock (); - tp->prio = CHX_PRIO_MAIN; + tp->prio = CHX_PRIO_MAIN_INIT; chopstx_main = (chopstx_t)tp; } +/** + * chopstx_main_init - initialize main thread + * @prio: priority + * + * Initialize main thread with @prio. + * The thread main is created with priority CHX_PRIO_MAIN_INIT, + * and it runs with that priority until this routine will is called. + */ +void +chopstx_main_init (chopstx_prio_t prio) +{ + struct chx_thread *tp = (struct chx_thread *)chopstx_main; + + tp->prio_orig = prio; + + if (prio >= CHOPSTX_PRIO_INHIBIT_PREEMPTION) + chx_cpu_sched_lock (); + + tp->prio = prio; +} + + static void chx_request_preemption (void) { @@ -31,6 +31,8 @@ typedef uint8_t chopstx_prio_t; extern chopstx_t chopstx_main; +void chopstx_main_init (chopstx_prio_t); + /* NOTE: This signature is different to PTHREAD's one. */ chopstx_t chopstx_create (uint32_t flags_and_prio, |