Delayed vs non-delayed Workqueues usage


todd_mullanix@...
 

Hi,

It's not clear to me what's the recommended usage of delayed vs non-delayed Workqueues. I see one of the example onĀ https://docs.zephyrproject.org/1.9.0/kernel/threads/workqueues.html
struct device_info {
    struct k_work work;
    char name[16]
} my_device;

void my_isr(void *arg)
{
    ...
    if (error detected) {
        k_work_submit(&my_device.work);
    }
    ...
}

void print_error(struct k_work *item) { struct device_info *the_device = CONTAINER_OF(item, struct device_info, work); printk("Got error on device %s\n", the_device->name); }
So if there is "extra" application content (name), it is placed after the struct k_work and the handler function will reference it accordingly. What if I wanted to send a k_delayed_work element to the same Workqueue. Can you intermix k_work and k_delayed_work structures on the same Workqueue? How do you know which structure type to use in the CONTAINER_OF? Do you have a "type" field before the k_work or k_delayed_work structure that the handler can query to determine what the real structure definition is?

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