2017-01-14 06:43:33 +08:00
|
|
|
.. _synchronization_sample:
|
|
|
|
|
2017-01-05 21:43:33 +08:00
|
|
|
Synchronization Sample
|
|
|
|
######################
|
|
|
|
|
|
|
|
Overview
|
2017-01-21 07:58:05 +08:00
|
|
|
********
|
2017-01-05 21:43:33 +08:00
|
|
|
|
2017-06-08 10:11:20 +08:00
|
|
|
A simple application that demonstrates basic sanity of the kernel.
|
2017-01-05 21:43:33 +08:00
|
|
|
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
|
2017-01-21 07:58:05 +08:00
|
|
|
********************
|
2017-01-05 21:43:33 +08:00
|
|
|
|
|
|
|
This project outputs to the console. It can be built and executed
|
|
|
|
on QEMU as follows:
|
|
|
|
|
2017-11-12 17:11:39 +08:00
|
|
|
.. zephyr-app-commands::
|
|
|
|
:zephyr-app: samples/synchronization
|
2018-01-18 00:32:31 +08:00
|
|
|
:host-os: unix
|
2017-11-12 17:11:39 +08:00
|
|
|
:board: qemu_x86
|
|
|
|
:goals: run
|
|
|
|
:compact:
|
2017-01-05 21:43:33 +08:00
|
|
|
|
2017-03-29 18:39:17 +08:00
|
|
|
On the supported ARM MCUs the project can be built with the MPU and the Thread
|
|
|
|
Stack Guard feature enabled:
|
|
|
|
|
2017-11-12 17:11:39 +08:00
|
|
|
.. zephyr-app-commands::
|
|
|
|
:zephyr-app: samples/synchronization
|
|
|
|
:board: v2m_beetle
|
|
|
|
:conf: prj_stack_guard.conf
|
|
|
|
:goals: build flash
|
|
|
|
:compact:
|
2017-03-29 18:39:17 +08:00
|
|
|
|
2017-01-05 21:43:33 +08:00
|
|
|
Sample Output
|
2017-01-21 07:58:05 +08:00
|
|
|
=============
|
2017-01-05 21:43:33 +08:00
|
|
|
|
|
|
|
.. 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>
|