New: chopstx_main_init

This commit is contained in:
NIIBE Yutaka
2015-04-18 12:19:43 +09:00
parent 2fb7fb6826
commit a0f33c1036
3 changed files with 35 additions and 5 deletions

View File

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

View File

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

View File

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