Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[fiber] Add stack overflow check in every yield#1219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
salkinium merged 7 commits intomodm-io:developfromsalkinium:feature/stkof
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
[fiber] Rename watermark_stack() to stack_watermark()
  • Loading branch information
@salkinium
salkinium committedNov 10, 2024
commitf6502bd89766c750fc081772dcc7b8f15277c8c4
8 changes: 4 additions & 4 deletionsexamples/avr/fiber/main.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -68,10 +68,10 @@ main()
MODM_LOG_INFO << "Starting fiber modm::yield benchmark..." << modm::endl;
MODM_LOG_INFO.flush();

fiber1.watermark_stack();
fiber2.watermark_stack();
fiber3.watermark_stack();
fiber4.watermark_stack();
fiber1.stack_watermark();
fiber2.stack_watermark();
fiber3.stack_watermark();
fiber4.stack_watermark();

const modm::PreciseTimestamp start = modm::PreciseClock::now();
modm::fiber::Scheduler::run();
Expand Down
16 changes: 8 additions & 8 deletionsexamples/generic/fiber/main.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -90,8 +90,8 @@ main()
MODM_LOG_INFO << "Starting fiber modm::yield benchmark..." << modm::endl;
MODM_LOG_INFO.flush();

fiber_y1.watermark_stack();
fiber_y2.watermark_stack();
fiber_y1.stack_watermark();
fiber_y2.stack_watermark();
// fiber_y1, fiber_y2 were autostarted
{
modm::atomic::Lock l;
Expand All@@ -103,10 +103,10 @@ main()
MODM_LOG_INFO.flush();

// the rest is manually started
fiber1.start(); fiber1.watermark_stack();
fiber2.start(); fiber2.watermark_stack();
fiber3.start(); fiber3.watermark_stack();
fiber4.start(); fiber4.watermark_stack();
fiber1.start(); fiber1.stack_watermark();
fiber2.start(); fiber2.stack_watermark();
fiber3.start(); fiber3.stack_watermark();
fiber4.start(); fiber4.stack_watermark();
const modm::PreciseTimestamp start = modm::PreciseClock::now();
modm::fiber::Scheduler::run();
const auto diff = (modm::PreciseClock::now() - start);
Expand All@@ -125,8 +125,8 @@ main()
MODM_LOG_INFO << "F3 stack usage = " << fiber3.stack_usage() << modm::endl;
MODM_LOG_INFO << "F4 stack usage = " << fiber4.stack_usage() << modm::endl;

fiber_ping.watermark_stack();
fiber_pong.watermark_stack();
fiber_ping.stack_watermark();
fiber_pong.stack_watermark();
fiber_ping.start();
modm::fiber::Scheduler::run();

Expand Down
14 changes: 7 additions & 7 deletionsexamples/nucleo_g071rb/amnb_fiber/main.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -152,13 +152,13 @@ main()
USART4->CR3 = USART_CR3_HDSEL;
USART4->CR1 |= USART_CR1_UE;

fiberNode1t.watermark_stack();
fiberNode1r.watermark_stack();
fiberNode2t.watermark_stack();
fiberNode2r.watermark_stack();
fiberNode3t.watermark_stack();
fiberNode3r.watermark_stack();
thread.watermark_stack();
fiberNode1t.stack_watermark();
fiberNode1r.stack_watermark();
fiberNode2t.stack_watermark();
fiberNode2r.stack_watermark();
fiberNode3t.stack_watermark();
fiberNode3r.stack_watermark();
thread.stack_watermark();

modm::fiber::Scheduler::run();

Expand Down
4 changes: 2 additions & 2 deletionssrc/modm/processing/fiber/context.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,12 +88,12 @@ modm_context_end();
* *NOT* while the fiber is running!
*/
void
modm_context_watermark(modm_context_t *ctx);
modm_context_stack_watermark(modm_context_t *ctx);

/**
* Returns the stack usage by searching from the bottom of the stack for the
* watermark level. You may call this function at any point after calling
* `modm_context_watermark()`.
* `modm_context_stack_watermark()`.
*/
size_t
modm_context_stack_usage(const modm_context_t *ctx);
Expand Down
2 changes: 1 addition & 1 deletionsrc/modm/processing/fiber/context_arm64.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -92,7 +92,7 @@ modm_context_reset(modm_context_t *ctx)
}

void
modm_context_watermark(modm_context_t *ctx)
modm_context_stack_watermark(modm_context_t *ctx)
{
// clear the register file on the stack
for (auto *word = ctx->top - StackWordsAll;
Expand Down
2 changes: 1 addition & 1 deletionsrc/modm/processing/fiber/context_arm_m.cpp.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,7 +118,7 @@ modm_context_reset(modm_context_t *ctx)
}

void
modm_context_watermark(modm_context_t *ctx)
modm_context_stack_watermark(modm_context_t *ctx)
{
// clear the register file on the stack
for (auto *word = ctx->top - StackWordsAll;
Expand Down
2 changes: 1 addition & 1 deletionsrc/modm/processing/fiber/context_avr.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -125,7 +125,7 @@ modm_context_reset(modm_context_t *ctx)
}

void
modm_context_watermark(modm_context_t *ctx)
modm_context_stack_watermark(modm_context_t *ctx)
{
// clear the register file on the stack
for (auto *word = p2u(ctx->top) - StackWordsAll;
Expand Down
2 changes: 1 addition & 1 deletionsrc/modm/processing/fiber/context_x86_64.cpp.in
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,7 +97,7 @@ modm_context_reset(modm_context_t *ctx)
}

void
modm_context_watermark(modm_context_t *ctx)
modm_context_stack_watermark(modm_context_t *ctx)
{
// clear the register file on the stack
for (auto *word = ctx->top - StackWordsAll;
Expand Down
2 changes: 1 addition & 1 deletionsrc/modm/processing/fiber/module.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -265,7 +265,7 @@ usage inside or outside the fiber:

```cpp
// You must watermark the stack *before* running the fiber!
fiber1.watermark_stack();
fiber1.stack_watermark();
// now you can run the fibers via the scheduler
modm::fiber::Scheduler::run();
// can be called from inside or outside the fiber, before or after running!
Expand Down
12 changes: 9 additions & 3 deletionssrc/modm/processing/fiber/task.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -127,11 +127,11 @@ class Task


/// Watermarks the stack to measure `stack_usage()` later.
/// @see `modm_context_watermark()`.
/// @see `modm_context_stack_watermark()`.
void inline
watermark_stack()
stack_watermark()
{
modm_context_watermark(&ctx);
modm_context_stack_watermark(&ctx);
}

/// @returns the stack usage as measured by a watermark level.
Expand DownExpand Up@@ -161,6 +161,12 @@ class Task
{
return scheduler;
}

/// @cond
// DEPRECATE: 2025q4
[[deprecated("Use `stack_watermark()` instead!")]]
void inline watermark_stack() { stack_watermark(); }
/// @endcond
};

}// namespace modm::fiber
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp