Task Scheduler  f3c51100
taskSch.h File Reference
#include <stdint.h>
#include <stdlib.h>
#include <stdatomic.h>
Include dependency graph for taskSch.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sch_task_package_t
 

Macros

#define TASH_SCH_EXTERN
 
#define SCH_FLAG_NO_AFM   0x80000000 /* Disable affinity mapping one to one between core and task pools. */
 
#define SCH_FLAG_INIT   0x1 /* Scheduler has been initialized. */
 
#define SCH_POOL_TERMINATE   0x1 /* Pool has been terminated. */
 
#define SCH_SIGNAL_IDLE   (schBaseSignal() + 0) /* */
 

Typedefs

typedef void *(* schFunc) (void *pdata)
 
typedef struct sch_task_package_t schTaskPackage
 

Enumerations

enum  SchErrCode
 Set of valid error codes. Anything equal to one or greater is considered as a success.
 

Functions

TASH_SCH_EXTERN int schAllocateTaskPool (schTaskSch **pSch)
 Allocate task scheduler object. It will make sure that for any version of the library, that the size of the internal structure are of correct size. More...
 
TASH_SCH_EXTERN int schCreateTaskPool (schTaskSch *sch, int cores, unsigned int flag, unsigned int maxPackagesPool)
 Initilize task scheduler internal data structure. More...
 
TASH_SCH_EXTERN int schReleaseTaskSch (schTaskSch *sch)
 Release all resources associated with the scheduler object. More...
 
TASH_SCH_EXTERN void schSetInitCallBack (schTaskSch *sch, schUserCallBack callBack)
 Set initialization callback that will be invoked when the scheduler starts. More...
 
TASH_SCH_EXTERN void schSetDeInitCallBack (schTaskSch *sch, schUserCallBack callBack)
 Set user deinitialize callback that will be invoked when the scheduler gets terminated. More...
 
TASH_SCH_EXTERN void schSetSchUserData (schTaskSch *sch, const void *user)
 Assign user data associated with the scheduler object. More...
 
TASH_SCH_EXTERN void schSetPoolUserData (schTaskSch *sch, int index, const void *user)
 Assign user data associated with the scheduler objects pools. More...
 
TASH_SCH_EXTERN void * schGetPoolUserData (schTaskSch *sch, int index)
 Get pool user data. More...
 
TASH_SCH_EXTERN schTaskPoolschGetPool (schTaskSch *sch, int index)
 Get scheduler pool by index. More...
 
TASH_SCH_EXTERN int schRunTaskSch (schTaskSch *sch)
 
TASH_SCH_EXTERN int schStopTaskSch (schTaskSch *sch, long int timeout_nanoseconds)
 
TASH_SCH_EXTERN int schTerminateTaskSch (schTaskSch *sch)
 
TASH_SCH_EXTERN int schSubmitTask (schTaskSch *sch, schTaskPackage *package, schTaskPool *pPool)
 
TASH_SCH_EXTERN int schClearTask (schTaskSch *sch, schTaskPool *pool)
 
TASH_SCH_EXTERN int schClearAllTask (schTaskSch *sch)
 
TASH_SCH_EXTERN int schWaitTask (schTaskSch *sch)
 
TASH_SCH_EXTERN int schWaitTaskWait (schTaskSch *sch, long int wait_nanoseconds)
 
TASH_SCH_EXTERN int schPoolLock (schTaskPool *pool)
 
TASH_SCH_EXTERN int schPoolMutexUnLock (schTaskPool *pool)
 
TASH_SCH_EXTERN schThread * schCreateThread (int affinity, schFunc pfunc, void *userData)
 Create new thread object with a custom callback entrypoint. More...
 
TASH_SCH_EXTERN int schDeleteThread (schThread *thread)
 Delete thread This will cause the system to release the thread resources. More...
 
TASH_SCH_EXTERN int schWaitThread (schThread *thread, void **retval)
 
TASH_SCH_EXTERN int schSetThreadName (schThread *thread, const char *name)
 
TASH_SCH_EXTERN schThread * schCurrentThread (void)
 
TASH_SCH_EXTERN int schRaiseThreadSignal (schThread *thread, int signal)
 
TASH_SCH_EXTERN schSignalSet * schCreateSignal (void)
 
TASH_SCH_EXTERN int schDeleteSignal (schSignalSet *signal)
 
TASH_SCH_EXTERN int schBaseSignal (void)
 
TASH_SCH_EXTERN int schSignalWait (schSignalSet *sig)
 Wait in till signal has been issued. More...
 
TASH_SCH_EXTERN int schSignalWaitTimeOut (schSignalSet *sig, long int nanoseconds)
 
TASH_SCH_EXTERN int schSetSignalThreadMask (schSignalSet *set, int nr, const int *signals)
 
TASH_SCH_EXTERN int schCreateMutex (schMutex **mutex)
 
TASH_SCH_EXTERN int schCreateSpinLock (schSpinLock **spinlock)
 Creates a spinlock synchronization primitive object. More...
 
TASH_SCH_EXTERN int schCreateSemaphore (schSemaphore **pSemaphore)
 
TASH_SCH_EXTERN int schCreateBarrier (schBarrier **pBarrier)
 Create Memory barrier. More...
 
TASH_SCH_EXTERN int schInitBarrier (schBarrier *pBarrier, int count)
 
TASH_SCH_EXTERN int schDeleteBarrier (schBarrier *barrier)
 
TASH_SCH_EXTERN int schWaitBarrier (schBarrier *barrier)
 Wait for the barrier to finish. More...
 
TASH_SCH_EXTERN int schCreateConditional (schConditional **pCondVariable)
 
TASH_SCH_EXTERN int schDeleteConditional (schConditional *conditional)
 
TASH_SCH_EXTERN int schConditionalWait (schConditional *conditional, schMutex *mutex)
 
TASH_SCH_EXTERN int schConditionalSignal (schConditional *conditional)
 
TASH_SCH_EXTERN int schCreateRWLock (schRWLock **pRwLock)
 
TASH_SCH_EXTERN int schDeleteRWLock (schRWLock *rwLock)
 
TASH_SCH_EXTERN int schRWLockRead (schRWLock *rwLock)
 
TASH_SCH_EXTERN int schRWLockWrite (schRWLock *rwLock)
 
TASH_SCH_EXTERN int schRWLocUnLock (schRWLock *rwLock)
 
TASH_SCH_EXTERN int schDeleteMutex (schMutex *mutex)
 Release resources associated with the mutex object. More...
 
TASH_SCH_EXTERN int schDeleteSpinLock (schSpinLock *spinlock)
 Release spinlock resources. More...
 
TASH_SCH_EXTERN int schDeleteSemaphore (schSemaphore *pSemaphore)
 Delete semaphore. More...
 
TASH_SCH_EXTERN int schMutexLock (schMutex *mutexLock)
 Lock mutex and wait initill it has been unlocked for the thread to use the mutex. More...
 
TASH_SCH_EXTERN int schMutexTryLock (schMutex *mutex, long int timeout)
 Attempt to lock the mutex. If the wait time exceeds the timeout it will return with the status of timeout. More...
 
TASH_SCH_EXTERN int schMutexUnLock (schMutex *mutexLock)
 Unlock mutex. More...
 
TASH_SCH_EXTERN int schSemaphoreWait (schSemaphore *pSemaphore)
 Wait for semaphore to be unlocked. More...
 
TASH_SCH_EXTERN int schSemaphoreTryWait (schSemaphore *semaphore)
 
TASH_SCH_EXTERN int schSemaphoreTimedWait (schSemaphore *pSemaphore, long int timeout)
 
TASH_SCH_EXTERN int schSemaphorePost (schSemaphore *pSemaphore)
 
TASH_SCH_EXTERN int schSemaphoreValue (schSemaphore *pSemaphore, int *value)
 
TASH_SCH_EXTERN int schLockSpinLock (schSpinLock *spinlock)
 
TASH_SCH_EXTERN int schTryLockSpinLock (schSpinLock *spinLock)
 
TASH_SCH_EXTERN int schUnlockSpinLock (schSpinLock *spinlock)
 
TASH_SCH_EXTERN const char * schErrorMsg (int errMsg)
 

Detailed Description

Main libtasksch public API header


Data Structure Documentation

◆ sch_task_package_t

struct sch_task_package_t

Scheduler task structure.

Data Fields
atomic_uint flag

Package flag.

unsigned int index

The pool index it being executed from.

schCallback callback

Callback function that the scheduler will be invoked.

size_t size

Size parameter.

size_t offset

Offset

void * begin

Start pointer.

void * end

End pointer.

void * puser

User data.

Macro Definition Documentation

◆ TASH_SCH_EXTERN

#define TASH_SCH_EXTERN

Macro for adding dynamic/shared library support.

◆ SCH_FLAG_NO_AFM

#define SCH_FLAG_NO_AFM   0x80000000 /* Disable affinity mapping one to one between core and task pools. */

Task scheduler option flags.

◆ SCH_FLAG_INIT

#define SCH_FLAG_INIT   0x1 /* Scheduler has been initialized. */

Task scheduler internal state flags.

◆ SCH_POOL_TERMINATE

#define SCH_POOL_TERMINATE   0x1 /* Pool has been terminated. */

Pool status flags.

◆ SCH_SIGNAL_IDLE

#define SCH_SIGNAL_IDLE   (schBaseSignal() + 0) /* */

Task scheduler signals.

Typedef Documentation

◆ schFunc

typedef void*(* schFunc) (void *pdata)

Task function callback type.

◆ schTaskPackage

Scheduler task structure.