samples/subsys/zbus/work_queue/README.html · samples/subsys/zbus/work_queue/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Zbus

Zbus Work Queue

한 sensor publication을 즉시·예약·thread 대기 방식으로 각각 처리합니다.

Official pathsamples/subsys/zbus/work_queue/README.html
Source filesamples/subsys/zbus/work_queue/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

아홉 handler에 동일한 temperature·pressure·humidity가 전달되는 흐름을 설명합니다.

Immediate

Listener callback

Deferred

System work queue

Threaded

Subscriber thread

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 818CF3CA3938CAA8123D5A7A998AE7ABA099A48326AD39E2EDCEE5C30A16E203
.. zephyr:code-sample:: zbus-work-queue
   :name: Work queue
   :relevant-api: zbus_apis

   Use a work queue to process zbus messages in various ways.

Overview
********
This sample implements an application using zbus to illustrate three different reaction options. First, the observer can react "instantaneously" by using a listener callback. It can schedule a job, pushing that to the system work queue. Last, it can wait and execute that in a subscriber thread.

Building and Running
********************

This project outputs to the console.  It can be built and executed
on QEMU as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/zbus/work_queue
   :host-os: unix
   :board: qemu_x86
   :goals: run

Sample Output
=============

.. code-block:: console

    I: Sensor msg processed by CALLBACK fh1: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by CALLBACK fh2: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by CALLBACK fh3: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by WORK QUEUE handler dh1: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by WORK QUEUE handler dh2: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by WORK QUEUE handler dh3: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by THREAD handler 1: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by THREAD handler 2: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by THREAD handler 3: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by CALLBACK fh1: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by CALLBACK fh2: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by CALLBACK fh3: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by WORK QUEUE handler dh1: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by WORK QUEUE handler dh2: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by WORK QUEUE handler dh3: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by THREAD handler 1: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by THREAD handler 2: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by THREAD handler 3: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by CALLBACK fh1: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by CALLBACK fh2: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by CALLBACK fh3: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by WORK QUEUE handler dh1: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by WORK QUEUE handler dh2: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by WORK QUEUE handler dh3: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by THREAD handler 1: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by THREAD handler 2: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by THREAD handler 3: temp = 30, press = 3, humidity = 300
    <continues>

Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.

Part 3

한국어 전문 번역

개요

이 sample은 Zbus message에 반응하는 세 가지 방법을 보여 주는 application입니다. 첫째, observer는 listener callback을 사용해 message에 즉시 반응할 수 있습니다. 둘째, job을 system work queue에 넣어 나중에 처리하도록 예약할 수 있습니다. 셋째, subscriber thread에서 message를 기다렸다가 처리할 수 있습니다.

빌드 및 실행

이 project는 console로 출력합니다. 다음 command로 QEMU의 qemu_x86에서 build하고 실행할 수 있습니다.

# From the root of the zephyr repository
west build -b qemu_x86 samples/subsys/zbus/work_queue
west build -t run

샘플 출력

각 sensor message는 세 callback handler fh1~fh3, 세 work queue handler dh1~dh3, 세 subscriber thread handler에서 각각 처리됩니다. Temperature·pressure·humidity 값은 10·1·100에서 20·2·200, 30·3·300으로 증가하며 같은 아홉 처리 경로가 반복됩니다.

I: Sensor msg processed by CALLBACK fh1: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by CALLBACK fh2: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by CALLBACK fh3: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by WORK QUEUE handler dh1: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by WORK QUEUE handler dh2: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by WORK QUEUE handler dh3: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by THREAD handler 1: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by THREAD handler 2: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by THREAD handler 3: temp = 10, press = 1, humidity = 100
I: Sensor msg processed by CALLBACK fh1: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by CALLBACK fh2: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by CALLBACK fh3: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by WORK QUEUE handler dh1: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by WORK QUEUE handler dh2: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by WORK QUEUE handler dh3: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by THREAD handler 1: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by THREAD handler 2: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by THREAD handler 3: temp = 20, press = 2, humidity = 200
I: Sensor msg processed by CALLBACK fh1: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by CALLBACK fh2: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by CALLBACK fh3: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by WORK QUEUE handler dh1: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by WORK QUEUE handler dh2: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by WORK QUEUE handler dh3: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by THREAD handler 1: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by THREAD handler 2: temp = 30, press = 3, humidity = 300
I: Sensor msg processed by THREAD handler 3: temp = 30, press = 3, humidity = 300
<continues>

QEMU를 종료하려면 CTRL+A를 누른 뒤 x를 누릅니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.