The code is too redundant, it is recommended to simplify to less than 100 lines, in fact, can be achieved with a single linked list. The looptime parameter is also unnecessary, you can pass a task pointer to the callback function and use the callback function to end the task.