|
tinykernel
|
#include <stdint.h>#include <stddef.h>#include "pico/runtime.h"Go to the source code of this file.
Classes | |
| struct | tk::TaskHandle |
| タスクの識別ハンドル More... | |
| class | tk::PreemptGuard |
| プリエンプション禁止をスコープ単位で安全に管理する RAII クラス More... | |
Namespaces | |
| namespace | tk |
| namespace | tk::detail |
Macros | |
| #define | TK_TICKS_PER_SEC 1000u |
| #define | TK_TIME_SLICE_MS 10u |
| #define | TK_MAX_TASKS 32u |
| #define | TK_DEFAULT_STACK_SIZE (4 * 1024) |
| #define | TK_TASK(fn, prio) |
| リンク時にタスクを自動登録するマクロ (静的タスク登録) | |
Typedefs | |
| using | tk::TaskFn = void (*)(void* arg) |
| using | tk::task_mask_t = uint32_t |
Enumerations | |
| enum | tk::Prio : uint32_t { tk::PRIO_REALTIME = 1 , tk::PRIO_HIGH = 5 , tk::PRIO_NORMAL = 9 , tk::PRIO_LOW = 13 } |
| タスクの優先度レベル More... | |
Functions | |
| TaskHandle | tk::create (TaskFn fn, void *arg=nullptr, uint32_t prio=PRIO_NORMAL) |
| タスクを生成・登録します | |
| void | tk::start () |
| tinykernel スケジューラを起動します | |
| void | tk::yield () |
| 現在実行中のタスクを一時中断し、同優先度の他のタスクへ CPU を譲渡します | |
| void | tk::sleep_ms (uint32_t ms) |
| 現在のタスクを指定時間スリープさせます | |
| void | tk::exit (int code=0) |
| 現在のタスクを終了・破棄します | |
| uint64_t | tk::now_ms () |
| システム起動時からの経過時間をミリ秒単位で取得します | |
| bool | tk::lock () |
| ハードウェアスピンロックと全割り込み禁止によるクリティカルセクションに入ります | |
| void | tk::unlock (bool was_enabled) |
| tk::lock() で入ったクリティカルセクションを抜けます | |
| void | tk::preempt_disable () |
| 自コアのタスクスイッチ (プリエンプション) を一時的に禁止します | |
| void | tk::preempt_enable () |
| 自コアのタスクスイッチ (プリエンプション) を再開します | |
| void | tk::detail::static_register (const char *name, TaskFn fn, uint32_t prio) |
| uint32_t | tk::detail::sched_lock () |
| void | tk::detail::sched_unlock (uint32_t save) |
| void | tk::detail::block_current_task_locked () |
| void | tk::detail::wake_task_locked (TaskHandle handle) |
| uint8_t | tk::detail::current_task_slot () |
| uint8_t | tk::detail::find_highest_prio_waiter (task_mask_t wait_mask) |
| #define TK_DEFAULT_STACK_SIZE (4 * 1024) |
1タスクあたりのスタックサイズ (バイト)
| #define TK_MAX_TASKS 32u |
最大タスク数 (スロット0はCore0アイドル、スロット1はCore1アイドル専用)
| #define TK_TASK | ( | fn, | |
| prio ) |
リンク時にタスクを自動登録するマクロ (静的タスク登録)
main() の開始前に Pico SDK のランタイムイニシャライザを利用してタスクを登録します。
| fn | タスク関数名 (void fn(void* arg)) |
| prio | タスク優先度 (例: tk::PRIO_NORMAL) |
| #define TK_TICKS_PER_SEC 1000u |
1秒あたりのタイマースケジューラtick数 (Hz)
| #define TK_TIME_SLICE_MS 10u |
同一優先度タスク間のタイムスライス時間 (ミリ秒)