#include <zephyr/kernel.h>
#include <zephyr/arch/cpu.h>
#include <zephyr/sys/arch_interface.h>
#include <zpp.hpp>
#include <chrono>
Go to the source code of this file.
◆ COUNT_LIMIT
◆ NUM_THREADS
◆ STACK_SIZE
#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE) |
◆ TCOUNT
◆ inc_count()
void inc_count |
( |
int |
my_id | ) |
|
|
noexcept |
Definition at line 34 of file main.cpp.
36 for (
int i = 0; i <
TCOUNT; i++) {
48 printk(
"%s: thread %d, count = %d Threshold reached.",
49 __func__, my_id, count);
50 count_threshold_cv.notify_one();
51 printk(
"Just sent signal.\n");
54 printk(
"%s: thread %d, count = %d, unlocking mutex\n",
55 __func__, my_id, count);
lock_guard using zpp::mutex as a lock.
auto sleep_for(const std::chrono::duration< T_Rep, T_Period > &sleep_duration)
Suspend the current thread for a specified time duration.
References COUNT_LIMIT, zpp::this_thread::sleep_for(), and TCOUNT.
Referenced by main().
◆ main()
Definition at line 86 of file main.cpp.
104 printk(
"Main(): Waited and joined with %d threads. Final value of count = %d. Done.\n",
Thread creation attributes.
static constexpr thread_prio preempt(int prio) noexcept
Create a preemptive priority value.
The class thread repecents a single Zephyr thread.
void inc_count(int my_id) noexcept
void watch_count(int my_id) noexcept
References inc_count(), zpp::no, NUM_THREADS, zpp::thread_prio::preempt(), and watch_count().
◆ watch_count()
void watch_count |
( |
int |
my_id | ) |
|
|
noexcept |
Definition at line 63 of file main.cpp.
65 printk(
"Starting %s: thread %d\n", __func__, my_id);
70 printk(
"%s: thread %d Count= %d. Going into wait...\n",
71 __func__, my_id, count);
73 count_threshold_cv.wait(lk);
75 printk(
"%s: thread %d Condition signal received. Count= %d\n",
76 __func__, my_id, count);
79 printk(
"%s: thread %d Updating the value of count...\n",
82 printk(
"%s: thread %d count now = %d.\n", __func__, my_id, count);
83 printk(
"%s: thread %d Unlocking mutex.\n", __func__, my_id);
zpp::unique_lock using zpp::mutex as a lock.
References COUNT_LIMIT.
Referenced by main().