-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathos_cfg.h
110 lines (82 loc) · 4.61 KB
/
os_cfg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
///////////////////////////////////////////////////////////////////////////////
// Copyright Christopher Kormanyos 2007 - 2024.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef OS_CFG_2011_10_20_H
#define OS_CFG_2011_10_20_H
#include <util/utility/util_time.h>
#include <cstddef>
#include <cstdint>
#include <limits>
// Declare the task initialization and the task function of the idle process.
namespace sys { namespace idle {
auto task_init() noexcept -> void; auto task_func() -> void;
} // namespace idle
} // namespace sys
// Define symbols for the task initialization and the task function of the idle process.
#define OS_IDLE_TASK_INIT() sys::idle::task_init()
#define OS_IDLE_TASK_FUNC() sys::idle::task_func()
// Declare all of the task initializations and the task functions.
namespace app { namespace led {
auto task_init() -> void; auto task_func() -> void;
} // namespace led
} // namespace app
namespace app { namespace benchmark {
auto task_init() -> void; auto task_func() -> void;
} // namespace benchmark
} // namespace app
namespace sys { namespace mon {
auto task_init() -> void; auto task_func() -> void;
} // namespace mon
} // namespace sys
namespace os
{
// Enumerate the task IDs. Note that the order in this list must
// be identical with the order of the tasks in the task list below.
enum class task_id_type // NOLINT(performance-enum-size)
{
task_id_app_led,
task_id_app_benchmark,
task_id_sys_mon,
task_id_end
};
// Configure the operating system types.
using function_type = void(*)();
using timer_type = util::timer<std::uint_fast32_t>;
using tick_type = timer_type::tick_type;
using event_type = std::uint_fast16_t;
static_assert(std::numeric_limits<os::tick_type>::digits >= static_cast<int>(INT8_C(32)),
"The operating system timer_type must be at least 32-bits wide.");
static_assert(std::numeric_limits<os::event_type>::digits >= static_cast<int>(INT8_C(16)),
"The operating system event_type must be at least 16-bits wide.");
} // namespace os
// Configure the operating system tasks.
// Use small prime numbers (representing microseconds) for task offsets.
// Use Wolfram's Alpha or Mathematica(R): Table[Prime[n], {n, 25, 1000, 25}]
// to obtain:
// 97, 229, 379, 541, 691, 863, 1039, 1223, 1427, 1583, 1777,
// 1987, 2153, 2357, 2557, 2741, 2953, 3181, 3371, 3571, 3769, 3989,
// 4201, 4409, 4637, 4831, 5039, 5279, 5483, 5693, 5881, 6133, 6337,
// 6571, 6793, 6997, 7237, 7499, 7687, 7919
constexpr auto OS_TASK_COUNT = static_cast<std::size_t>(os::task_id_type::task_id_end);
#define OS_TASK_LIST \
{ \
{ \
os::task_control_block(app::led::task_init, \
app::led::task_func, \
os::timer_type::microseconds(UINT32_C( 4000)), \
os::timer_type::microseconds(UINT32_C( 0))), \
os::task_control_block(app::benchmark::task_init, \
app::benchmark::task_func, \
os::timer_type::microseconds(UINT32_C( 750000)), \
os::timer_type::microseconds(UINT32_C( 379))), \
os::task_control_block(sys::mon::task_init, \
sys::mon::task_func, \
os::timer_type::microseconds(UINT32_C( 27000)), \
os::timer_type::microseconds(UINT32_C( 541))), \
} \
}
static_assert(OS_TASK_COUNT > static_cast<std::size_t>(UINT8_C(0)), "the task count must exceed zero");
#endif // OS_CFG_2011_10_20_H