The Task Scheduler is a simple task scheduler library for distributing the tasks over a set of threads of cores.
Features
- Task Scheduling - with a priority queue, currently a simple version based on the average delta time.
- Synchronization primitives - used either with the task scheduler or with other multithreading components in the application.
Motivation
The original purpose was to create a simple task scheduler that could be used for game engines for distributing the loads on the various individual game engine components such as frustum culling, animation and etc.
Installation
The software can be easily installed with invoking the following command.
mkdir build && cd build
cmake ..
cmake --build .
make install
Development Build
For building for development, the following commands can be used.
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build .
Integration with CMake
The idea is to be able to integrate this library with another project easily. With CMake, it basically requires 2 lines. One for adding the project and the second for adding it as a dependent linked library target.
ADD_SUBDIRECTORY(task-scheduler EXCLUDE_FROM_ALL)
TARGET_LINK_LIBRARIES(myTarget PUBLIC taskSch)
Examples
The following a simple example for creating the scheduler object, running it and releasing the resources.
int main(int argc, const char** argv){
const size_t numPackages = 250;
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
TASH_SCH_EXTERN int schCreateTaskPool(schTaskSch *sch, int cores, unsigned int flag, unsigned int maxPackagesPool)
Initilize task scheduler internal data structure.
TASH_SCH_EXTERN int schAllocateTaskPool(schTaskSch **pSch)
Allocate task scheduler object. It will make sure that for any version of the library,...
TASH_SCH_EXTERN int schReleaseTaskSch(schTaskSch *sch)
Release all resources associated with the scheduler object.
TASH_SCH_EXTERN int schRunTaskSch(schTaskSch *sch)
Task scheduler main struct container.
Definition: internal_structures.h:75
#define SCH_FLAG_NO_AFM
Definition: taskSch.h:88
The following line demonstrates how to compile it and link the program, using gcc:
gcc *.c -o task-sch-example -ltaskSch
Unit Testing
The unit testing program for asserting the behavior of the program requires a set of Dependencies, see the following.
apt-get install check libsubunit-dev
The only dependency is the pthread for Unix machines.
License
This project is licensed under the LGPL+3 License - see the [LICENSE](LICENSE) file for more details.