forked from len0rd/rockbox
kernel: Break out kernel primitives into separate files and move to separate dir.
No code changed, just shuffling stuff around. This should make it easier to build only select parts kernel and use different implementations. Change-Id: Ie1f00f93008833ce38419d760afd70062c5e22b5
This commit is contained in:
parent
8bae5f2644
commit
382d1861af
30 changed files with 1564 additions and 756 deletions
|
|
@ -682,3 +682,53 @@ void thread_get_name(char *buffer, int size,
|
|||
snprintf(buffer, size, fmt, name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Unless otherwise defined, do nothing */
|
||||
#ifndef YIELD_KERNEL_HOOK
|
||||
#define YIELD_KERNEL_HOOK() false
|
||||
#endif
|
||||
#ifndef SLEEP_KERNEL_HOOK
|
||||
#define SLEEP_KERNEL_HOOK(ticks) false
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Suspends a thread's execution for at least the specified number of ticks.
|
||||
*
|
||||
* May result in CPU core entering wait-for-interrupt mode if no other thread
|
||||
* may be scheduled.
|
||||
*
|
||||
* NOTE: sleep(0) sleeps until the end of the current tick
|
||||
* sleep(n) that doesn't result in rescheduling:
|
||||
* n <= ticks suspended < n + 1
|
||||
* n to n+1 is a lower bound. Other factors may affect the actual time
|
||||
* a thread is suspended before it runs again.
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
unsigned sleep(unsigned ticks)
|
||||
{
|
||||
/* In certain situations, certain bootloaders in particular, a normal
|
||||
* threading call is inappropriate. */
|
||||
if (SLEEP_KERNEL_HOOK(ticks))
|
||||
return 0; /* Handled */
|
||||
|
||||
disable_irq();
|
||||
sleep_thread(ticks);
|
||||
switch_thread();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Elects another thread to run or, if no other thread may be made ready to
|
||||
* run, immediately returns control back to the calling thread.
|
||||
*---------------------------------------------------------------------------
|
||||
*/
|
||||
void yield(void)
|
||||
{
|
||||
/* In certain situations, certain bootloaders in particular, a normal
|
||||
* threading call is inappropriate. */
|
||||
if (YIELD_KERNEL_HOOK())
|
||||
return; /* handled */
|
||||
|
||||
switch_thread();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue