Difference between revisions of "Zephyr rtos threads"

From Wiki at Neela Nurseries
Jump to: navigation, search
m
m
Line 24: Line 24:
  
 
<!-- comment -->
 
<!-- comment -->
 +
 +
== [[#top|^]] Example Zephyr Thread Creation ==
 +
Rough search narrowing in on specific thread creation and use in aws_iot sample project from nRF Connect SDK:
 +
<pre>
 +
cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$ grep -nr k_ ./*.c
 +
30:static struct k_work_delayable shadow_update_work;
 +
31:static struct k_work_delayable connect_work;
 +
32:static struct k_work shadow_update_version_work;
 +
150:static void connect_work_fn(struct k_work *work)
 +
166:    k_work_schedule(&connect_work,
 +
170:static void shadow_update_work_fn(struct k_work *work)
 +
186:    k_work_schedule(&shadow_update_work,
 +
190:static void shadow_update_version_work_fn(struct k_work *work)
 +
242:            (void)k_work_cancel_delayable(&connect_work);
 +
258:            k_work_submit(&shadow_update_version_work);
 +
262:            k_work_schedule(&shadow_update_work,
 +
283:            (void)k_work_cancel_delayable(&shadow_update_work);
 +
284:            k_work_schedule(&connect_work, K_NO_WAIT);
 +
335:static void work_init(void)
 +
337:    k_work_init_delayable(&shadow_update_work, shadow_update_work_fn);
 +
338:    k_work_init_delayable(&connect_work, connect_work_fn);
 +
339:    k_work_init(&shadow_update_version_work, shadow_update_version_work_fn);
 +
356:            k_sem_give(&lte_connected);
 +
513:    work_init();
 +
523:    k_sem_take(&lte_connected, K_FOREVER);
 +
528:    k_work_schedule(&connect_work, K_NO_WAIT);
 +
 +
cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$ grep -n connect_work ./*.c
 +
31:static struct k_work_delayable connect_work;
 +
150:static void connect_work_fn(struct k_work *work)
 +
166:    k_work_schedule(&connect_work,
 +
242:            (void)k_work_cancel_delayable(&connect_work);
 +
284:            k_work_schedule(&connect_work, K_NO_WAIT);
 +
338:    k_work_init_delayable(&connect_work, connect_work_fn);
 +
528:    k_work_schedule(&connect_work, K_NO_WAIT);
 +
cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$
 +
 +
</pre>

Revision as of 23:18, 28 September 2021

Some Zephyr RTOS API functions to learn:

    • k_sem_take(&lte_connected, K_FOREVER);
    • k_work_schedule(&connect_work, K_NO_WAIT);

Unsure whether this routine a Zephyr one:

 work_init();


Following non-function entities from aws_iot main.c appear important:

77 static struct k_work_delayable shadow_update_work;
78 static struct k_work_delayable connect_work;
79 static struct k_work shadow_update_version_work;


^ Specific Zephyr documentation pages


^ Example Zephyr Thread Creation

Rough search narrowing in on specific thread creation and use in aws_iot sample project from nRF Connect SDK:

cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$ grep -nr k_ ./*.c
30:static struct k_work_delayable shadow_update_work;
31:static struct k_work_delayable connect_work;
32:static struct k_work shadow_update_version_work;
150:static void connect_work_fn(struct k_work *work)
166:    k_work_schedule(&connect_work,
170:static void shadow_update_work_fn(struct k_work *work)
186:    k_work_schedule(&shadow_update_work,
190:static void shadow_update_version_work_fn(struct k_work *work)
242:            (void)k_work_cancel_delayable(&connect_work);
258:            k_work_submit(&shadow_update_version_work);
262:            k_work_schedule(&shadow_update_work,
283:            (void)k_work_cancel_delayable(&shadow_update_work);
284:            k_work_schedule(&connect_work, K_NO_WAIT);
335:static void work_init(void)
337:    k_work_init_delayable(&shadow_update_work, shadow_update_work_fn);
338:    k_work_init_delayable(&connect_work, connect_work_fn);
339:    k_work_init(&shadow_update_version_work, shadow_update_version_work_fn);
356:            k_sem_give(&lte_connected);
513:    work_init();
523:    k_sem_take(&lte_connected, K_FOREVER);
528:    k_work_schedule(&connect_work, K_NO_WAIT);

cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$ grep -n connect_work ./*.c
31:static struct k_work_delayable connect_work;
150:static void connect_work_fn(struct k_work *work)
166:    k_work_schedule(&connect_work,
242:            (void)k_work_cancel_delayable(&connect_work);
284:            k_work_schedule(&connect_work, K_NO_WAIT);
338:    k_work_init_delayable(&connect_work, connect_work_fn);
528:    k_work_schedule(&connect_work, K_NO_WAIT);
cpguest@ubuntu-vm-0p2:/mnt/host-os-dev-area/pulse-pro/firmware-stage1/aws-iot-stand-alone/src$