portYIELD() in preemptive mode

imajeff wrote on Wednesday, October 12, 2005:

I’m trying to work out some functions on a board with a port to GCC/HCS12 that is not proven yet. I have been successful with two tasks on different priority, who toggle an LED using vTaskDelay(). I’ve tested this with either portYIELD() or preemptive mode. It was working after my message
at 2005-08-05 16:35

Now I am apparently stuck on using vApplicationIdleHook(), which may not be execuding, and don’t know if I’m using portYIELD() properly.

I use preemptive mode. In a task, priority 1, I have these lines
.    while (!(SCISR1 & RDRF))
.        portYIELD();

  I think this is supposed to mean that on every kernel tick, it would check for the flag above (because it’s the highest priority), and then if not flag it would execute the idle hook for the rest of the tick period.  Am I wrong? I don’t ever see the output I coded in the idle hook.

nobody wrote on Wednesday, October 12, 2005:

portYIELD() forces a context switch, but if the task calling yield is the highest priority task in the system it will run again immediately as you have not asked it to block, therefore the idle task will never execute.  Try using vTaskDelay(1) instead.  This will block the calling task until the next tick.

imajeff wrote on Wednesday, October 12, 2005:

Yeah, thanks.  I guess Yield only has a use in the same-priority group (and cooperative mode).

Someday I hope I can follow this scheduler implementation. Funny, having no background in task swapping, I thought it would be more complex than it is. I’m not the type to rely on school or books, so it has been a challenge getting started.