Work Queue

A work queue service provides a timer API for other FW parts. A timer API client (a component, device, etc.) registers a callback and specifies when the callback should be invoked.

Refer to TBD for full API specification.

A source of time for the work queue is implemented by the specific platform and depends on the underlying architecture and the HW capabilities which determine the resolution of the timer.

class "struct work" as s_work {
hide s_work methods

enum flags {
hide flags methods

class "struct work_queue_timesource" as s_wq_timesource
hide s_wq_timesource methods
hide s_wq_timesource attributes

class "work_queue" as wq {
   + work_schedule()
   + work_reschedule()
   + work_cancel()
   - is_work_pending()
   - work_next_timeout()
   - run_work()
   - work : list

class client #a1a1ca
hide client methods
hide client attributes

wq o- s_work
wq <- s_wq_timesource : provides timer INT

s_work - flags

client -> s_work : (1) creates
client ---> wq : (2) schedules work
wq ---> client : (3) calls cb(cb_data) upon timeout

Figure 25 Work queue dependencies

Basic Work Queue Flow

actor client as c

participant work_queue as wq
participant timer as t

-> wq : work_new_queue
   wq -> t : timer_register(queue_run)
<-- wq

c -> wq : work_schedule(&work)
   activate wq

   wq -> wq : queue_reschedule()
   activate wq
      wq -> wq : queue_get_next_timeout() : timeout
      wq -> t : work_set_timer(timeout)
   deactivate wq
c <-- wq
deactivate wq
wq <- t : queue_run()
   activate wq
   loop is_work_pending()
      wq -> wq : run_work()
   end loop
   wq -> wq : queue_reschedule()

Figure 26 Basic work queue flow

Extensions for SMP Architectures

CPUs with platforms built on the SMP architecture contain only one work queue instance. A client registers its callback in the queue instance that is running on the CPU that the callback is supposed to run.