Cleanup of nanokernel's fiber scheduling routine

1) Renames routine to conform to kernel naming conventions.
2) Relocates routine declaration to include files for
   non-public nanokernel APIs.
3) Relocates routine definition so that it resides with the
   nanokernel's other fiber manipulation routines.
4) Eliminates an unnecessary argument to the routine.

Change-Id: Ia139280dfea36262ca8417708786b4989f3eaee1
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This commit is contained in:
Allan Stephens 2015-06-03 15:39:21 -04:00 committed by Anas Nashif
parent 24dd3044ca
commit 69555e8efd
7 changed files with 44 additions and 50 deletions

View File

@ -264,7 +264,7 @@ static ALWAYS_INLINE int _IS_IN_ISR(void)
return ((act & 0xffff) != 0);
}
extern void _insert_ccs(tCCS **, tCCS *);
extern void _nano_fiber_schedule(tCCS *ccs);
extern void _nano_fiber_swap(void);
extern void _NewContext(char *, unsigned, _ContextEntry,
_ContextArg, _ContextArg, _ContextArg,

View File

@ -198,7 +198,7 @@ static ALWAYS_INLINE void fiberRtnValueSet(
pEsf->a1 = value;
}
extern void _insert_ccs(tCCS **, tCCS *);
extern void _nano_fiber_schedule(tCCS *ccs);
extern void _nano_fiber_swap(void);
extern void _NewContext(char *,
unsigned,

View File

@ -857,7 +857,7 @@ typedef unsigned char __aligned(_EXC_STUB_ALIGN) NANO_EXC_STUB[_EXC_STUB_SIZE];
extern void nano_cpu_atomic_idle(unsigned int imask);
extern unsigned _Swap(unsigned int mask);
extern void _insert_ccs(tCCS **queue, tCCS *ccs);
extern void _nano_fiber_schedule(tCCS *ccs);
extern void _nano_fiber_swap(void);

View File

@ -63,7 +63,7 @@ static inline tCCS *_nano_wait_q_remove_no_check(struct _nano_queue *wait_q)
}
ccs->link = 0;
_insert_ccs((tCCS **)&_nanokernel.fiber, ccs);
_nano_fiber_schedule(ccs);
return ccs;
}

View File

@ -277,43 +277,3 @@ FUNC_NORETURN void _context_entry(
CODE_UNREACHABLE;
}
/*******************************************************************************
*
* _insert_ccs - add a context into the list of runnable contexts
*
* The list of runnable contexts is maintained via a single linked list
* in priority order. Numerically lower priorities represent higher priority
* contexts.
*
* \NOMANUAL
*
* RETURNS: N/A
*/
void _insert_ccs(tCCS **queue, tCCS *ccs)
{
tCCS *pQ;
pQ = (tCCS *)queue;
/*
* Scan the "queue" until end of list or until context with numerically
* higher priority is located. A context will be placed at the end of
* the series of equal priority contexts.
*/
while (pQ->link && (ccs->prio >= pQ->link->prio)) {
pQ = pQ->link;
}
/*
* Insert context. A context will be placed at the end of equal
* priority
* contexts.
*/
ccs->link = pQ->link;
pQ->link = ccs;
}

View File

@ -41,6 +41,40 @@ either in the form of an actual function or an alias to a function.
#include <toolchain.h>
#include <sections.h>
/*******************************************************************************
*
* _nano_fiber_schedule - add a fiber to the list of runnable fibers
*
* The list of runnable fibers is maintained via a single linked list
* in priority order. Numerically lower priorities represent higher priority
* contexts.
*
* Interrupts must already be locked to ensure list cannot change
* while this routine is executing!
*
* RETURNS: N/A
*/
void _nano_fiber_schedule(tCCS *ccs)
{
tCCS *pQ = (tCCS *)&_nanokernel.fiber;
/*
* Search until end of list or until a fiber with numerically
* higher priority is located.
*/
while (pQ->link && (ccs->prio >= pQ->link->prio)) {
pQ = pQ->link;
}
/* Insert fiber, following any equal priority fibers */
ccs->link = pQ->link;
pQ->link = ccs;
}
/* currently the fiber and task implementations are identical */
FUNC_ALIAS(_fiber_start, fiber_fiber_start, void);
@ -92,13 +126,13 @@ void _fiber_start(char *pStack,
/* _NewContext() has already set the flags depending on the 'options'
* and 'priority' parameters passed to it */
/* lock interrupts to prevent corruption of the runnable context list */
/* lock interrupts to prevent corruption of the runnable fiber list */
imask = irq_lock();
/* insert thew newly crafted CCS into the fiber runnable context list */
/* make the newly crafted CCS a runnable fiber */
_insert_ccs((tCCS **)&_nanokernel.fiber, ccs);
_nano_fiber_schedule(ccs);
/*
* Simply return to the caller if the current context is FIBER,
@ -137,7 +171,7 @@ void fiber_yield(void)
* then swap to the context at the head of the fiber list.
*/
_insert_ccs(&(_nanokernel.fiber), _nanokernel.current);
_nano_fiber_schedule(_nanokernel.current);
_Swap(imask);
} else
irq_unlock_inline(imask);

View File

@ -110,7 +110,7 @@ void _stack_push_non_preemptible(
if (ccs) {
stack->fiber = 0;
fiberRtnValueSet(ccs, data);
_insert_ccs((tCCS **)&_nanokernel.fiber, ccs);
_nano_fiber_schedule(ccs);
} else {
*(stack->next) = data;
stack->next++;
@ -144,7 +144,7 @@ void nano_task_stack_push(
if (ccs) {
stack->fiber = 0;
fiberRtnValueSet(ccs, data);
_insert_ccs((tCCS **)&_nanokernel.fiber, ccs);
_nano_fiber_schedule(ccs);
_Swap(imask);
return;
} else {