#ifndef _xmk_sleep_h_ #define _xmk_sleep_h_ /*---------------------------------------------------------------------------- ** SUMMARY: XMK Thread Sleep Interfaces (SLEEP) ** ** DESCRIPTION: ** This file provides the interface for delaying/sleeping a thread. Currently ** there are two implementation of this interface. Listed below are the pros and ** cons of each. ** ** Basic/Default - USE_XMK_THREAD_SLEEP ** PROS: ** o Very small ROM and RAM footprint ** o Simple, i.e. not much to go wrong and is deterministic. ** CONS: ** o Evaulates *every* thread on every timer/sleep tick interrupt. ** o Many counter decrements per tick interrupt. ** o Does not scale well as the number of threads increase. ** ** Alternate - USE_XMK_THREAD_XSLEEP ** PROS: ** o Only evaulates the sleeping threads per tick interruput. ** o At most only one counter is decremented per tick interrupt. ** o Scales better to a large number of threads. ** CONS: ** o Larger ROM and RAM footprint. ** o Does not scale perfectly to a large number of threads. ** o The amount of time required to "put" a thread to sleep ** is function of the total number of currently sleeping threads. ** ** CONFIGURATION OPTION: USE_XMK_THREAD_SLEEP or ** USE_XMK_THREAD_XSLEEP ** ** DEPENDENCIES: ** To use this interface the following XMK service(s) MUST always be ** enabled/configured: ** USE_XMK_CORE_KERNEL ** ** NOTES: ** 1. For efficency/optimization some methods are 'inlined'. The inlining ** is done by using the preprocessor/macros. The application should ** treat all methods as function calls and not rely on the fact they may ** be currently defined as a macro. ** ----------------------------------------------------------------------------*/ #include "xmkcfg.h" /* For: Project/Application kernel configuraiton */ #ifdef __cplusplus extern "C" { #endif /*-------------- MAGIC CONSTANTS -------------------------------------------*/ /** Number of 'sleep' ticks in 1 second. */ #define XMK_NUM_SLEEPTICKS_PER_SECOND _XMK_NUM_SLEEPTICKS_PER_SECOND /** Maximum possible sleep time in ticks */ #define XMK_SLEEP_MAX_DELAY _XMK_SLEEP_MAX_DELAY /*-------------- PUBLIC/PUBLISHED API --------------------------------------*/ /** This puts the current thread to sleep (i.e. yeild the CPU) for the specified number of sleep ticks. The Sleep time is measured in 'sleep' ticks since power-up. The duration of a 'sleep' tick is platform/implementation specific (it is usually the same time base as the system timer, but not always). The amount of real time the thread will sleep for is AT LEAST 'delayInTicks-1' sleep ticks. The thread will only yeild the CPU if the speficied ticks is greater than zero. Prototype: void Xmk_sleep(XMK_SLEEPTICKS delayInTicks); */ #define Xmk_sleep(n) _Xmk_sleep(n) #ifdef __cplusplus } #endif /*--------------------------------------------------------------------------*/ #endif /* end _xmk_sleep_h_ */