Re: RFC: make _fiber_start() return a handle on the fiber


Benjamin Walsh <benjamin.walsh@...>
 

On Wed, Feb 24, 2016 at 03:04:41PM +0200, Jukka Rissanen wrote:
I think I figured this out:

- I was trying to wake up the same fiber I was running
- I was always calling fiber_fiber_wakeup() instead of proper context
depending version
Yeah, that would do it: the task has to yield to the fiber somehow,
since it will never pend (in a nanokernel context).

After fixing these two issues, the fiber wake up seems to work now
fine.

I would suggest that if possible, the wake up code could check that we
are not trying to wake ourselves.
Hmm, I would counter this with the argument that passing the current
fiber context is the same as passing any other invalid value. There are
absolutely no checks being done to see if the handle is a pointer to a
valid fiber.

However, I think there is an issue if the caller tries to a wake up a
fiber that was potentially sleeping but that has waken up, and is not
running yet. In that case, that will corrupt the fiber ready queue since
the fiber will be pointing to itself for the next fiber to run.
If a fiber is not waiting, it should not be added to the ready queue
(since it's already in the ready queue). The interesting thing with this
fix is that it would catch a fiber trying to wake itself up, since it is
not sleeping.

Join devel@lists.zephyrproject.org to automatically receive all group messages.