File tree Expand file tree Collapse file tree 7 files changed +40
-1
lines changed
src/modm/processing/fiber Expand file tree Collapse file tree 7 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,12 @@ modm_context_stack_watermark(modm_context_t *ctx);
97
97
*/
98
98
size_t
99
99
modm_context_stack_usage (const modm_context_t * ctx );
100
+
101
+ /**
102
+ * Returns the configured stack size.
103
+ */
104
+ size_t
105
+ modm_context_stack_size (const modm_context_t * ctx );
100
106
/// @}
101
107
102
108
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -113,6 +113,12 @@ modm_context_stack_usage(const modm_context_t *ctx)
113
113
return 0 ;
114
114
}
115
115
116
+ size_t
117
+ modm_context_stack_size (const modm_context_t *ctx)
118
+ {
119
+ return (ctx->top - ctx->bottom ) * StackSizeWord;
120
+ }
121
+
116
122
static modm_context_t main_context;
117
123
118
124
uintptr_t
Original file line number Diff line number Diff line change @@ -139,6 +139,12 @@ modm_context_stack_usage(const modm_context_t *ctx)
139
139
return 0;
140
140
}
141
141
142
+ size_t
143
+ modm_context_stack_size(const modm_context_t *ctx)
144
+ {
145
+ return (ctx->top - ctx->bottom) * StackSizeWord;
146
+ }
147
+
142
148
#define MODM_PUSH_CONTEXT() \
143
149
%% if is_cm0
144
150
"push {r4-r7, lr} \n\t" \
Original file line number Diff line number Diff line change @@ -146,6 +146,12 @@ modm_context_stack_usage(const modm_context_t *ctx)
146
146
return 0 ;
147
147
}
148
148
149
+ size_t
150
+ modm_context_stack_size (const modm_context_t *ctx)
151
+ {
152
+ return (ctx->top - ctx->bottom ) * StackSizeWord;
153
+ }
154
+
149
155
extern " C" uintptr_t modm_context_jump_entry (modm_context_t *, modm_context_t *);
150
156
extern " C" void modm_context_jump_return (uintptr_t , modm_context_t *);
151
157
static uintptr_t main_context_sp;
Original file line number Diff line number Diff line change @@ -120,6 +120,12 @@ modm_context_stack_usage(const modm_context_t *ctx)
120
120
return 0;
121
121
}
122
122
123
+ size_t
124
+ modm_context_stack_size(const modm_context_t *ctx)
125
+ {
126
+ return (ctx->top - ctx->bottom) * StackSizeWord;
127
+ }
128
+
123
129
static modm_context_t main_context;
124
130
125
131
uintptr_t
Original file line number Diff line number Diff line change @@ -289,7 +289,8 @@ fiber1.stack_watermark();
289
289
// now you can run the fibers via the scheduler
290
290
modm::fiber::Scheduler::run ();
291
291
// can be called from inside or outside the fiber, before or after running!
292
- size_t bytes = fiber.stack_usage();
292
+ size_t total = fiber.stack_size();
293
+ size_t used = fiber.stack_usage();
293
294
```
294
295
295
296
Note that stack usage measurement through watermarking can be inaccurate if the
Original file line number Diff line number Diff line change @@ -142,6 +142,14 @@ class Task
142
142
return modm_context_stack_usage (&ctx);
143
143
}
144
144
145
+ // / @returns the available stack size excluding the storage of the callable.
146
+ // / @see `modm_context_stack_size()`.
147
+ [[nodiscard]] size_t inline
148
+ stack_size () const
149
+ {
150
+ return modm_context_stack_size (&ctx);
151
+ }
152
+
145
153
// / Adds the task to the currently active scheduler, if not already running.
146
154
// / @returns if the fiber has been scheduled.
147
155
bool
You can’t perform that action at this time.
0 commit comments