Hi, I writing a new app based on the new Keil 5 CMSIS-RTOS Version 1.02, I wanted to be able to suspend and resume a task, several times in another task,
I have used osThreadTerminate for suspending and I'm using osThreadCreate for resuming, But the problem with that is I'm making several copy Tasks!
Here is the code that I'm using
void enable_alarm(void) { if( t_AlarmTask = osThreadCreate(osThread(AlarmTask), NULL); } void disable_alarm(void) { osThreadTerminate(t_AlarmTask); } void FlasherTask (void const *argument) { while(1) { disable_alarm(); //Do some stuff enable_alarm(); //Do some other things osDelay(1); } }
Do you have any Idea how I should suspend and resume?
If the scheduler can't suspend and resume then it's up to you to implement cooperative suspend.
Ok, I will take the responsibility,But how I should implement it? any hints?
The running thread obviously have too cooperate and look at something to know when it should suspend. And then it's business as usual to just wait for an event to know when it can resume again.
The only issue is that the thread can only suspend and resume at fixed points in the code.
If you find that the "CIMCIS RTOS" is not suitable for your requirements, find another one which is!
You did check the specifications before using it, didn't you...?