1.. _cpp_synchronization: 2 3C++ Synchronization 4################### 5 6Overview 7******** 8The sample project illustrates usage of pure virtual class, member 9functions with different types of arguments, global objects constructor 10invocation. 11 12A simple application demonstrates basic sanity of the kernel. The main thread 13and a cooperative thread take turns printing a greeting message to the console, 14and use timers and semaphores to control the rate at which messages are 15generated. This demonstrates that kernel scheduling, communication, and 16timing are operating correctly. 17 18Building and Running 19******************** 20 21This kernel project outputs to the console. It can be built and executed 22on QEMU as follows: 23 24.. zephyr-app-commands:: 25 :zephyr-app: samples/cpp/cpp_synchronization 26 :host-os: unix 27 :board: qemu_x86 28 :goals: run 29 :compact: 30 31Sample Output 32============= 33 34.. code-block:: console 35 36 Create semaphore 0x001042b0 37 Create semaphore 0x001042c4 38 main: Hello World! 39 coop_thread_entry: Hello World! 40 main: Hello World! 41 coop_thread_entry: Hello World! 42 main: Hello World! 43 coop_thread_entry: Hello World! 44 main: Hello World! 45 coop_thread_entry: Hello World! 46 main: Hello World! 47 coop_thread_entry: Hello World! 48 main: Hello World! 49 coop_thread_entry: Hello World! 50 main: Hello World! 51 coop_thread_entry: Hello World! 52 main: Hello World! 53 coop_thread_entry: Hello World! 54 main: Hello World! 55 coop_thread_entry: Hello World! 56 main: Hello World! 57 58 <repeats endlessly> 59 60Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`. 61