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:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2017-01-07 07:49:24 +08:00
|
|
|
$ cd samples/synchronization
|
2017-01-08 05:31:34 +08:00
|
|
|
$ make run
|
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:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ cd samples/synchronization
|
|
|
|
$ make BOARD=v2m_beetle CONF_FILE=prj_stack_guard.conf
|
|
|
|
|
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>
|