Part 1
요약·해설
Thread A/B의 semaphore handoff와 반복 console 출력을 설명합니다.
A · B
Semaphore
Scheduling · Timing
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
4578F9CDB4899EDE02BF23612BB01AE32E436659C03E25BA26EA606F8CDAFE85
.. zephyr:code-sample:: synchronization
:name: Basic Synchronization
:relevant-api: thread_apis semaphore_apis
Manipulate basic kernel synchronization primitives.
Overview
********
A simple application that demonstrates basic sanity of the kernel.
Two threads (A and B) take turns printing a greeting message to the console,
and use sleep requests and semaphores to control the rate at which messages
are generated. This demonstrates that kernel scheduling, communication,
and timing are operating correctly.
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/synchronization
:host-os: unix
:board: qemu_x86
:goals: run
:compact:
Sample Output
=============
.. code-block:: console
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
<repeats endlessly>
Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.
Part 3
한국어 전문 번역
개요
Kernel의 기본 동작이 정상인지 확인하는 간단한 application입니다. 두 thread A와 B가 console에 greeting message를 번갈아 출력하며, sleep request와 semaphore를 사용해 message 생성 속도를 제어합니다. 이를 통해 kernel scheduling, thread 사이 communication과 timing이 올바르게 작동하는지 확인할 수 있습니다.
빌드 및 실행
이 project는 console로 출력합니다. 다음 command로 QEMU의 qemu_x86에서 build하고 실행할 수 있습니다.
west build -b qemu_x86 samples/synchronization
west build -t run
샘플 출력
Thread A와 B가 semaphore로 실행 순서를 넘겨주면서 Hello World!를 정확히 교대로 출력합니다. 같은 pattern은 끝없이 반복됩니다.
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
threadA: Hello World!
threadB: Hello World!
<repeats endlessly>
QEMU를 종료하려면 CTRL+A를 누른 뒤 x를 누릅니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.