[PATCH v2 02/11] common: introduce bthreads, co-operative barebox threads
Peter Korsgaard
peter at korsgaard.com
Mon Mar 1 07:42:07 EST 2021
>>>>> "Ahmad" == Ahmad Fatoum <a.fatoum at pengutronix.de> writes:
Hi,
> +bthreads
> +--------
> +
> +barebox threads are co-operative green threads, which are scheduled whenever
> +``is_timeout()`` is called. This has a few implications. First of all,
> +bthreads are not scheduled when ``is_timeout()`` is not called.
> +For this and other reasons, loops polling for hardware events should always
> +use a timeout, which is best implemented with ``is_timeout()``.
> +Another thing to remember is that bthreads can be scheduled anywhere
> +in the middle of other device accesses whenever ``is_timeout()`` is
> +called. Care must be taken that a green thread doesn't access the very same device
> +again itself. See "slices" below on how devices can safely be accessed from
> +bthreads.
> +
> +Unlike pollers, which bthreads are replacing, bthreads are allowed
> +access to virtual filesystem. The macro ``assert_command_context()`` is added
> +to entry points of the VFS to have the thread yield until it may execute in
> +in the correct context. The poller interface is declared in
s/poller/bthread/
> +``include/bthread.h``. ``bthread_create()`` is used to allocate a bthread
> +control block along with its stack. ``bthread_wake()`` can be used to hang
> +it into the run queue. From this moment on and until the thread terminates,
s/hang it into/add/
> +the thread will be switched to regularly as long as someone calls
> +``is_timeout()``. bthreads are allowed to call ``is_timeout()``, which will
> +arrange for other threads to execute.
> +
> +barebox threads replace previous the previous pollers and workqueues. Poller
s/previous the previous/the previous infrastructure,/
--
Bye, Peter Korsgaard
More information about the barebox
mailing list