diff options
author | Thomas Martitz <kugel@rockbox.org> | 2013-12-04 17:06:17 +0100 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2014-03-03 18:11:57 +0100 |
commit | 382d1861af12741af4ff235b9d18f179c0adc4c5 (patch) | |
tree | 26166c130d2889bb1ae1082e8f7aba103534f49e /firmware/target/hosted/sdl/thread-sdl.c | |
parent | 8bae5f2644b5d5759499fbf1066b9c35c6f859ad (diff) | |
download | rockbox-382d1861af12741af4ff235b9d18f179c0adc4c5.tar.gz rockbox-382d1861af12741af4ff235b9d18f179c0adc4c5.zip |
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
Diffstat (limited to 'firmware/target/hosted/sdl/thread-sdl.c')
-rw-r--r-- | firmware/target/hosted/sdl/thread-sdl.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/firmware/target/hosted/sdl/thread-sdl.c b/firmware/target/hosted/sdl/thread-sdl.c index fbc26c8a9f..c17e793833 100644 --- a/firmware/target/hosted/sdl/thread-sdl.c +++ b/firmware/target/hosted/sdl/thread-sdl.c | |||
@@ -682,3 +682,53 @@ void thread_get_name(char *buffer, int size, | |||
682 | snprintf(buffer, size, fmt, name); | 682 | snprintf(buffer, size, fmt, name); |
683 | } | 683 | } |
684 | } | 684 | } |
685 | |||
686 | /* Unless otherwise defined, do nothing */ | ||
687 | #ifndef YIELD_KERNEL_HOOK | ||
688 | #define YIELD_KERNEL_HOOK() false | ||
689 | #endif | ||
690 | #ifndef SLEEP_KERNEL_HOOK | ||
691 | #define SLEEP_KERNEL_HOOK(ticks) false | ||
692 | #endif | ||
693 | |||
694 | |||
695 | /*--------------------------------------------------------------------------- | ||
696 | * Suspends a thread's execution for at least the specified number of ticks. | ||
697 | * | ||
698 | * May result in CPU core entering wait-for-interrupt mode if no other thread | ||
699 | * may be scheduled. | ||
700 | * | ||
701 | * NOTE: sleep(0) sleeps until the end of the current tick | ||
702 | * sleep(n) that doesn't result in rescheduling: | ||
703 | * n <= ticks suspended < n + 1 | ||
704 | * n to n+1 is a lower bound. Other factors may affect the actual time | ||
705 | * a thread is suspended before it runs again. | ||
706 | *--------------------------------------------------------------------------- | ||
707 | */ | ||
708 | unsigned sleep(unsigned ticks) | ||
709 | { | ||
710 | /* In certain situations, certain bootloaders in particular, a normal | ||
711 | * threading call is inappropriate. */ | ||
712 | if (SLEEP_KERNEL_HOOK(ticks)) | ||
713 | return 0; /* Handled */ | ||
714 | |||
715 | disable_irq(); | ||
716 | sleep_thread(ticks); | ||
717 | switch_thread(); | ||
718 | return 0; | ||
719 | } | ||
720 | |||
721 | /*--------------------------------------------------------------------------- | ||
722 | * Elects another thread to run or, if no other thread may be made ready to | ||
723 | * run, immediately returns control back to the calling thread. | ||
724 | *--------------------------------------------------------------------------- | ||
725 | */ | ||
726 | void yield(void) | ||
727 | { | ||
728 | /* In certain situations, certain bootloaders in particular, a normal | ||
729 | * threading call is inappropriate. */ | ||
730 | if (YIELD_KERNEL_HOOK()) | ||
731 | return; /* handled */ | ||
732 | |||
733 | switch_thread(); | ||
734 | } | ||