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
|
|
|
|
|
|
|
A simple application that demonstates 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
|
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
|
|
|
|
|
|
|
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>
|