thread_switch_to

Norman Feske norman.feske at ...1...
Fri Feb 10 12:19:22 CET 2012


Hi Martin,

> I have a question about 'static inline void
> thread_switch_to(Native_thread_id tid)'. This function shall yield to a
> given thread, but what is the expected behavior if the targeted thread
> exists and is started but also paused?

normally, this function is called by the lock implementation to help a
lock-applying thread to enter the kernel (via 'thread_stop_myself') when
the lock is contended. In the normal case, the thread needs no help for
that. But very rarely, the kernel may preempt the thread just before it
was able to call 'thread_stop_myself' (see the longish prose at line 122
in 'base/lock/lock.cc') and pass control to the lock owner, which
releases the lock.


https://github.com/genodelabs/genode/blob/master/base/src/base/lock/lock.cc

If the thread is already blocked, there is nothing to do. I'd suggest to
just return to the user land.

Cheers
Norman




More information about the users mailing list