blob: 3566d2713338220f8a3f3c1023c885d1b935a70a (
plain)
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
|
// Copyright 2023 The Pigweed Authors
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#include "pw_thread/thread.h"
#include "pw_thread_zephyr/config.h"
#include "pw_thread_zephyr/options.h"
namespace pw::system {
using namespace pw::thread::zephyr::config;
// Low to high priorities.
enum class ThreadPriority : int {
kWorkQueue = kDefaultPriority,
// TODO(amontanez): These should ideally be at different priority levels, but
// there's synchronization issues when they are.
kLog = kWorkQueue,
kRpc = kWorkQueue,
kNumPriorities,
};
static constexpr size_t kLogThreadStackWords =
CONFIG_PIGWEED_SYSTEM_TARGET_HOOKS_LOG_STACK_SIZE;
static thread::zephyr::StaticContextWithStack<kLogThreadStackWords>
log_thread_context;
const thread::Options& LogThreadOptions() {
static constexpr auto options =
pw::thread::zephyr::Options(log_thread_context)
.set_priority(static_cast<int>(ThreadPriority::kLog));
return options;
}
static constexpr size_t kRpcThreadStackWords =
CONFIG_PIGWEED_SYSTEM_TARGET_HOOKS_RPC_STACK_SIZE;
static thread::zephyr::StaticContextWithStack<kRpcThreadStackWords>
rpc_thread_context;
const thread::Options& RpcThreadOptions() {
static constexpr auto options =
pw::thread::zephyr::Options(rpc_thread_context)
.set_priority(static_cast<int>(ThreadPriority::kRpc));
return options;
}
static constexpr size_t kWorkQueueThreadStackWords =
CONFIG_PIGWEED_SYSTEM_TARGET_HOOKS_WORK_QUEUE_STACK_SIZE;
static thread::zephyr::StaticContextWithStack<kWorkQueueThreadStackWords>
work_queue_thread_context;
const thread::Options& WorkQueueThreadOptions() {
static constexpr auto options =
pw::thread::zephyr::Options(work_queue_thread_context)
.set_priority(static_cast<int>(ThreadPriority::kWorkQueue));
return options;
}
} // namespace pw::system
|