CorePartition
|
Macros | |
#define | NOTRACE 1 ? (void)0 : (void)printf |
#define | VERIFY(term, ret) |
#define | YYTRACE printf |
#define | TRACE NOTRACE |
#define | Cpx_SetBit(var, bitValue) (var |= bitBValue) |
#define | Cpx_UnsetBit(var, bitValue) (var &= (~bitValue)) |
#define | Cpx_ToggleBit(var, bitValue) (var ^= bitValue) |
#define | THREADL_ER_STACKOVFLW 1 /* Stack Overflow */ |
#define | THREAD_FACTOR_MAXBYTES 8 |
#define | THREAD_NAME_MAX 8 |
#define | Cpx_SetState(nNewState) pCurrentThread->nStatus = nNewState |
#define | Cpx_NowYield() |
#define | POLY 0x8408 |
#define | _CPTHREAD(T) pCpxThread[T] |
Enumerations | |
enum | __cp_lock_type { CP_LOCK_NONE = 0 , CP_LOCK_SIMPLE , CP_LOCK_SHARED } |
enum | __cpx_thread_controller_type { CPX_CTRL_TYPE_STATIC = 1 , CPX_CTRL_BROKER_STATIC = 2 } |
Functions | |
uint32_t | Cpx_GetCurrentTick (void) |
void | Cpx_SleepTicks (uint32_t nSleepTime) |
void | Cpx_StackOverflowHandler (void) |
bool | Cpx_IsCoreRunning (void) |
Report if there is any running thread. More... | |
void | Cpx_InternalSetNice (uint32_t nNice) |
void | Cpx_InternalSetStatus (uint8_t nStatus) |
uint16_t | Cpx_CRC16 (const uint8_t *pData, size_t nSize, uint16_t nCRC) |
bool | Cpx_StaticStart (CpxThread **ppStaticThread, size_t nStaticThreadSize) |
Start CorePartition thread provisioning. More... | |
bool | Cpx_Start (size_t nThreadPartitions) |
Start CorePartition thread provisioning. More... | |
bool | Cpx_CreateThread (void(*pFunction)(void *), void *pValue, size_t nStackMaxSize, uint32_t nNice) |
Create a non-Isolated context Thread. More... | |
bool | Cpx_CreateStaticThread (void(*pFunction)(void *), void *pValue, CpxStaticThread *pStaticThread, size_t nStaticThreadSize, uint32_t nNice) |
Create a Thread using a static Context + virtual stack page. More... | |
void | Cpx_Join (void) |
This will start all the threads. More... | |
uint8_t | Cpx_Yield (void) |
Function to be called inside a thread to change context. More... | |
void | Cpx_SetSleep (uint32_t nDelayTickTime) |
Will set the thread sleep parameter before Yield. More... | |
size_t | Cpx_GetID (void) |
Get Current Thread ID. More... | |
size_t | Cpx_GetStackSizeByID (size_t nID) |
Get Current Thread ID. More... | |
size_t | Cpx_GetMaxStackSizeByID (size_t nID) |
Get total size of stack context page for a Thread ID. More... | |
uint32_t | Cpx_GetNiceByID (size_t nID) |
Current Thread Nice. More... | |
uint8_t | Cpx_GetStatusByID (size_t nID) |
Get a thread status for a thread ID. More... | |
uint32_t | Cpx_GetLastDutyCycleByID (size_t nID) |
Last Duty Cycle of the current Thread. More... | |
uint32_t | Cpx_GetLastMomentumByID (size_t nID) |
Get Current Thread last momentum on switch back. More... | |
size_t | Cpx_GetNumberOfActiveThreads (void) |
Get Number of total active Threads. More... | |
size_t | Cpx_GetNumberOfThreads (void) |
Get Number of assigned Threads. More... | |
size_t | Cpx_GetMaxNumberOfThreads (void) |
Get Max Number of total active Threads. More... | |
size_t | Cpx_GetStructContextSize (void) |
Get Thread context size. More... | |
size_t | Cpx_GetContextSizeByID (size_t nID) |
Get Full context size (Contex + stack + Broker) More... | |
void | Cpx_SetNice (uint32_t nNice) |
Set Current Thread Nice. More... | |
bool | Cpx_IsThreadStaticByID (size_t nID) |
Return if a Threads was statically initiated. More... | |
bool | Cpx_IsBrokerStaticByID (size_t nID) |
Return if a Thread's Broker interface was statically initiated. More... | |
bool | Cpx_EnableStaticBroker (void *pUserContext, CpxStaticBroker *pStaticBroker, size_t nStaticBrokerSize, TopicCallback callback) |
Enable Broker for the current thread. More... | |
bool | Cpx_EnableBroker (void *pUserContext, uint16_t nMaxTopics, TopicCallback callback) |
Enable Broker for the current thread. More... | |
bool | Cpx_IsSubscribed (const char *pszTopic, size_t length) |
Check if the current thread already subscribe to a topic. More... | |
bool | Cpx_SubscribeTopic (const char *pszTopic, size_t length) |
Subscribe for a specific topic. More... | |
bool | Cpx_PublishTopic (const char *pszTopic, size_t length, size_t nAttribute, uint64_t nValue) |
Public a tuple Param and Value. More... | |
bool | Cpx_WaitMessage (const char *pszTag, size_t nTagLength, CpxMsgPayload *payload) |
Wait for a specific notification from a given TAG and payload. More... | |
bool | Cpx_Wait (const char *pszTag, size_t nTagLength) |
Wait for a specific notification from a given TAG. More... | |
bool | Cpx_SetTopicID (const char *pszTag, size_t nTagLength, uint32_t *pnTopicID) |
bool | Cpx_NotifyOne (const char *pszTag, size_t nTagLength) |
Notify ONE TAG assigned as waiting thread. More... | |
bool | Cpx_NotifyMessageOne (const char *pszTag, size_t nTagLength, size_t nAttribute, uint64_t nValue) |
Notify ONE TAGs assigned as waiting thread with a Message payload. More... | |
bool | Cpx_NotifyAll (const char *pszTag, size_t nTagLength) |
Notify ALL TAGs assigned as waiting thread. More... | |
bool | Cpx_NotifyMessageAll (const char *pszTag, size_t nTagLength, size_t nAttribute, uint64_t nValue) |
Notify ALL TAGs assigned as waiting thread with a Message payload. More... | |
bool | Cpx_WaitVariableLock (void *pnLockID, size_t *pnStatus) |
Wait for a Variable Locks notification. More... | |
size_t | Cpx_NotifyVariableLock (void *pnLockID, size_t nStatus, bool bOneOnly) |
Notify all/one Variable lock waiting for notification. More... | |
size_t | Cpx_WaitingVariableLock (void *pnLockID) |
Return how much threads are locked waiting for a variable notification. More... | |
bool | Cpx_LockInit (CpxSmartLock *pLock) |
Init SmartLock variable. More... | |
bool | Cpx_TryLock (CpxSmartLock *pLock) |
Like Lock() but only locks in case it is unlocked. More... | |
bool | Cpx_Lock (CpxSmartLock *pLock) |
Do a exclusive Lock and set to Simple lock. More... | |
bool | Cpx_SharedLock (CpxSmartLock *pLock) |
Can act as multiple locks. More... | |
bool | Cpx_SharedUnlock (CpxSmartLock *pLock) |
Unlock shared locks. More... | |
bool | Cpx_Unlock (CpxSmartLock *pLock) |
Unlock exclusive locks. More... | |
void * | Cpx_GetLockID () |
void * | Cpx_GetLockIDByID (size_t nID) |
Variables | |
CpxThread ** | pCpxThread = NULL |
CpxThread * | pCurrentThread = NULL |
void * | pStartStck = NULL |
jmp_buf | jmpJoinPointer |
#define _CPTHREAD | ( | T | ) | pCpxThread[T] |
#define Cpx_NowYield | ( | ) |
#define Cpx_SetBit | ( | var, | |
bitValue | |||
) | (var |= bitBValue) |
#define Cpx_SetState | ( | nNewState | ) | pCurrentThread->nStatus = nNewState |
#define Cpx_ToggleBit | ( | var, | |
bitValue | |||
) | (var ^= bitValue) |
#define Cpx_UnsetBit | ( | var, | |
bitValue | |||
) | (var &= (~bitValue)) |
#define NOTRACE 1 ? (void)0 : (void)printf |
#define POLY 0x8408 |
#define THREAD_FACTOR_MAXBYTES 8 |
#define THREAD_NAME_MAX 8 |
#define THREADL_ER_STACKOVFLW 1 /* Stack Overflow */ |
#define TRACE NOTRACE |
#define VERIFY | ( | term, | |
ret | |||
) |
#define YYTRACE printf |
enum __cp_lock_type |
uint16_t Cpx_CRC16 | ( | const uint8_t * | pData, |
size_t | nSize, | ||
uint16_t | nCRC | ||
) |
bool Cpx_CreateStaticThread | ( | void(*)(void *) | pFunction, |
void * | pValue, | ||
CpxStaticThread * | pStaticThread, | ||
size_t | nStaticThreadSize, | ||
uint32_t | nNice | ||
) |
Create a Thread using a static Context + virtual stack page.
pFunction | Function (void Function (void* dataPointer)) as thread main |
pValue | data that will be injected on Thread creation |
pStaticThread | The Static context + virtual stack pointer |
nStaticThreadSize | Size of the Static Thread in bytes |
nNice | When in time it is good to be used |
bool Cpx_CreateThread | ( | void(*)(void *) | pFunction, |
void * | pValue, | ||
size_t | nStackMaxSize, | ||
uint32_t | nNice | ||
) |
Create a non-Isolated context Thread.
pFunction | Function (void Function (void* dataPointer)) as thread main |
pValue | data that will be injected on Thread creation |
nStackMaxSize | Size of the Stack to be used |
nNice | When in time it is good to be used |
bool Cpx_EnableBroker | ( | void * | pUserContext, |
uint16_t | nMaxTopics, | ||
TopicCallback | callback | ||
) |
Enable Broker for the current thread.
pUserContext | The default context to be ejected if needed |
nMaxTopics | Max topics to be handled by the current thread |
callback | Call back to be used to process thread Synchronously |
bool Cpx_EnableStaticBroker | ( | void * | pUserContext, |
CpxStaticBroker * | pStaticBroker, | ||
size_t | nStaticBrokerSize, | ||
TopicCallback | callback | ||
) |
Enable Broker for the current thread.
pUserContext | The default context to be ejected if needed |
pStaticBroker | Static Broker CpxSubscriptions pointer |
nStaticBrokerSize | Static Broker CpxSubscriptions pointer size in bytes |
callback | Call back to be used to process thread Synchronously |
size_t Cpx_GetContextSizeByID | ( | size_t | nID | ) |
Get Full context size (Contex + stack + Broker)
uint32_t Cpx_GetCurrentTick | ( | void | ) |
size_t Cpx_GetID | ( | void | ) |
Get Current Thread ID.
uint32_t Cpx_GetLastDutyCycleByID | ( | size_t | nID | ) |
Last Duty Cycle of the current Thread.
nID | Thread ID |
uint32_t Cpx_GetLastMomentumByID | ( | size_t | nID | ) |
Get Current Thread last momentum on switch back.
nID | Thread ID |
void* Cpx_GetLockID | ( | void | ) |
void* Cpx_GetLockIDByID | ( | size_t | nID | ) |
size_t Cpx_GetMaxNumberOfThreads | ( | void | ) |
Get Max Number of total active Threads.
size_t Cpx_GetMaxStackSizeByID | ( | size_t | nID | ) |
Get total size of stack context page for a Thread ID.
nID | Thread ID |
uint32_t Cpx_GetNiceByID | ( | size_t | nID | ) |
Current Thread Nice.
nID | Thread ID |
size_t Cpx_GetNumberOfActiveThreads | ( | void | ) |
Get Number of total active Threads.
size_t Cpx_GetNumberOfThreads | ( | void | ) |
Get Number of assigned Threads.
size_t Cpx_GetStackSizeByID | ( | size_t | nID | ) |
Get Current Thread ID.
nID | A valid ID |
uint8_t Cpx_GetStatusByID | ( | size_t | nID | ) |
Get a thread status for a thread ID.
nID | Thread ID |
size_t Cpx_GetStructContextSize | ( | void | ) |
Get Thread context size.
void Cpx_InternalSetNice | ( | uint32_t | nNice | ) |
void Cpx_InternalSetStatus | ( | uint8_t | nStatus | ) |
bool Cpx_IsBrokerStaticByID | ( | size_t | nID | ) |
Return if a Thread's Broker interface was statically initiated.
nID | Thread ID |
bool Cpx_IsCoreRunning | ( | void | ) |
Report if there is any running thread.
bool Cpx_IsSubscribed | ( | const char * | pszTopic, |
size_t | length | ||
) |
Check if the current thread already subscribe to a topic.
pszTopic | The topic for information |
length | The size of the topic string |
bool Cpx_IsThreadStaticByID | ( | size_t | nID | ) |
Return if a Threads was statically initiated.
nID | Thread ID |
void Cpx_Join | ( | void | ) |
This will start all the threads.
bool Cpx_Lock | ( | CpxSmartLock * | pLock | ) |
Do a exclusive Lock and set to Simple lock.
pLock | The Lock variable |
bool Cpx_LockInit | ( | CpxSmartLock * | pLock | ) |
Init SmartLock variable.
pLock | The Lock variable |
bool Cpx_NotifyAll | ( | const char * | pszTag, |
size_t | nTagLength | ||
) |
Notify ALL TAGs assigned as waiting thread.
pszTag | The Tag string value |
nTagLength | The length of the tag |
bool Cpx_NotifyMessageAll | ( | const char * | pszTag, |
size_t | nTagLength, | ||
size_t | nAttribute, | ||
uint64_t | nValue | ||
) |
Notify ALL TAGs assigned as waiting thread with a Message payload.
pszTag | The TAG string value |
nTagLength | The length of the tag |
nAttribute | The Attribute Value to be sent |
nValue | The Value of the Attribute to be sent |
bool Cpx_NotifyMessageOne | ( | const char * | pszTag, |
size_t | nTagLength, | ||
size_t | nAttribute, | ||
uint64_t | nValue | ||
) |
Notify ONE TAGs assigned as waiting thread with a Message payload.
pszTag | The Tag string value |
nTagLength | The length of the tag |
nAttribute | The Attribute Value to be sent |
nValue | The Value of the Attribute to be sent |
bool Cpx_NotifyOne | ( | const char * | pszTag, |
size_t | nTagLength | ||
) |
Notify ONE TAG assigned as waiting thread.
pszTag | The Tag string value |
nTagLength | The length of the tag |
size_t Cpx_NotifyVariableLock | ( | void * | nLockID, |
size_t | nStatus, | ||
bool | bOneOnly | ||
) |
Notify all/one Variable lock waiting for notification.
nLockID | Variable address |
nStatus | Payload to be sent, a size_t |
bOneOnly | If true only one is notified |
bool Cpx_PublishTopic | ( | const char * | pszTopic, |
size_t | length, | ||
size_t | nAttribute, | ||
uint64_t | nValue | ||
) |
Public a tuple Param and Value.
pszTopic | Topic name to publish |
length | The size of the topic string |
nAttribute | A attribute to be use to identify the value |
nValue | A value for the attribute (tuple) |
void Cpx_SetNice | ( | uint32_t | nNice | ) |
Set Current Thread Nice.
nNice | Nice to be used |
void Cpx_SetSleep | ( | uint32_t | nDelayTickTime | ) |
Will set the thread sleep parameter before Yield.
nDelayTickTime | How much ticks to sleep |
bool Cpx_SetTopicID | ( | const char * | pszTag, |
size_t | nTagLength, | ||
uint32_t * | pnTopicID | ||
) |
bool Cpx_SharedLock | ( | CpxSmartLock * | pLock | ) |
Can act as multiple locks.
pLock | The Lock variable |
bool Cpx_SharedUnlock | ( | CpxSmartLock * | pLock | ) |
Unlock shared locks.
pLock | The Lock variable |
void Cpx_SleepTicks | ( | uint32_t | nSleepTime | ) |
void Cpx_StackOverflowHandler | ( | void | ) |
bool Cpx_Start | ( | size_t | nThreadPartitions | ) |
Start CorePartition thread provisioning.
nThreadPartitions | Number of threads to be provisioned |
bool Cpx_StaticStart | ( | CpxThread ** | ppStaticThread, |
size_t | nStaticThreadSize | ||
) |
Start CorePartition thread provisioning.
ppStaticThread | Static Thread pointer type CpxThread** |
nStaticThreadSize | Static Thread size in bytes |
bool Cpx_SubscribeTopic | ( | const char * | pszTopic, |
size_t | length | ||
) |
Subscribe for a specific topic.
pszTopic | The topic to listen for information |
length | The size of the topic string |
bool Cpx_TryLock | ( | CpxSmartLock * | pLock | ) |
Like Lock() but only locks in case it is unlocked.
pLock | The Lock variable |
bool Cpx_Unlock | ( | CpxSmartLock * | pLock | ) |
Unlock exclusive locks.
pLock | The Lock variable |
bool Cpx_Wait | ( | const char * | pszTag, |
size_t | nTagLength | ||
) |
Wait for a specific notification from a given TAG.
pszTag | The Tag string value |
nTagLength | The length of the tag |
size_t Cpx_WaitingVariableLock | ( | void * | nLockID | ) |
Return how much threads are locked waiting for a variable notification.
nLockID | Variable address |
bool Cpx_WaitMessage | ( | const char * | pszTag, |
size_t | nTagLength, | ||
CpxMsgPayload * | payload | ||
) |
Wait for a specific notification from a given TAG and payload.
pszTag | The Tag string value |
nTagLength | The length of the tag |
payload | The payload with the information sent by other thread |
bool Cpx_WaitVariableLock | ( | void * | nLockID, |
size_t * | pnStatus | ||
) |
Wait for a Variable Locks notification.
nLockID | Variable address |
pnStatus | Payload to be sent, a size_t |
uint8_t Cpx_Yield | ( | void | ) |
Function to be called inside a thread to change context.
jmp_buf jmpJoinPointer |
CpxThread** pCpxThread = NULL |
CpxThread* pCurrentThread = NULL |
void* pStartStck = NULL |