samples/basic/threads/README.html · samples/basic/threads/README.rst 공식 원문 ↗

Zephyr 3.7.0 · Samples · Kernel

기본 thread 조작

100 ms와 1000 ms 주기의 LED toggle event를 FIFO로 세 번째 출력 thread에 전달합니다.

Official pathsamples/basic/threads/README.html
Source filesamples/basic/threads/README.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

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

Part 1

요약·해설

led0·led1 alias 요구사항, build 오류와 96Boards Carbon build·flash 절차를 설명합니다.

Threads

3 compile-time

Cycles

100 ms · 1000 ms

Queue

FIFO → printk

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 28794E5F6B42E5B2DEA262895D40AE15E6BA6DDBE48F711664E1B74A08F8243B
.. zephyr:code-sample:: multi-thread-blinky
   :name: Basic thread manipulation
   :relevant-api: gpio_interface thread_apis

   Spawn multiple threads that blink LEDs and print information to the console.

Overview
********

This example demonstrates spawning multiple threads using
:c:func:`K_THREAD_DEFINE`. It spawns three threads. Each thread is then defined
at compile time using K_THREAD_DEFINE.

The first two each control an LED. These LEDs, ``led0`` and ``led1``, have
loop control and timing logic controlled by separate functions.

- ``blink0()`` controls ``led0`` and has a 100ms sleep cycle
- ``blink1()`` controls ``led1`` and has a 1000ms sleep cycle

When either of these threads toggles its LED, it also pushes information into a
:ref:`FIFO <fifos_v2>` identifying the thread/LED and how many times it has
been toggled.

The third thread uses :c:func:`printk` to print the information added to the
FIFO to the device console.

Requirements
************

The board must have two LEDs connected via GPIO pins. These are called "User
LEDs" on many of Zephyr's :ref:`boards`. The LEDs must be configured using the
``led0`` and ``led1`` :ref:`devicetree <dt-guide>` aliases, usually in the
:ref:`BOARD.dts file <devicetree-in-out-files>`.

You will see one of these errors if you try to build this sample for an
unsupported board:

.. code-block:: none

   Unsupported board: led0 devicetree alias is not defined
   Unsupported board: led1 devicetree alias is not defined

Building
********

For example, to build this sample for :ref:`96b_carbon_board`:

.. zephyr-app-commands::
   :zephyr-app: samples/basic/threads
   :board: 96b_carbon/stm32f401xe
   :goals: build flash
   :compact:

Change ``96b_carbon/stm32f401xe`` appropriately for other supported boards.

Part 3

한국어 전문 번역

개요

이 예제는 K_THREAD_DEFINE을 사용해 여러 thread를 생성하는 방법을 보여줍니다. 모두 세 개의 thread를 만들며, 각 thread는 compile time에 K_THREAD_DEFINE으로 정의됩니다.

처음 두 thread는 각각 LED 하나를 제어합니다. led0과 led1의 loop 제어와 timing logic은 서로 다른 함수가 담당합니다.

  • blink0()는 led0을 제어하며 sleep cycle은 100 ms입니다.
  • blink1()는 led1을 제어하며 sleep cycle은 1000 ms입니다.

두 thread 중 하나가 LED를 toggle할 때마다 thread/LED 식별자와 지금까지 toggle한 횟수를 FIFO에 넣습니다.

세 번째 thread는 printk를 사용해 FIFO에 추가된 정보를 device console에 출력합니다.

요구사항

Board에는 GPIO pin을 통해 연결된 LED 두 개가 있어야 합니다. 많은 Zephyr board에서 이를 User LED라고 부릅니다. LED는 보통 BOARD.dts file에서 led0과 led1 Devicetree alias로 configuration해야 합니다.

지원하지 않는 board에서 이 sample을 build하면 다음 오류 중 하나가 나타납니다.

Unsupported board: led0 devicetree alias is not defined
Unsupported board: led1 devicetree alias is not defined

Build

예를 들어 96b_carbon_board용으로 build하고 flash하려면 다음 명령을 실행합니다.

west build -b 96b_carbon/stm32f401xe samples/basic/threads
west flash

다른 지원 board를 사용하려면 96b_carbon/stm32f401xe를 해당 board 이름으로 바꾸십시오.

Source

출처

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