Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trace deadline violations #457

Merged
merged 5 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
2 changes: 2 additions & 0 deletions core/reactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,15 @@ int _lf_do_step(environment_t* env) {
// Deadline violation has occurred.
violation = true;
// Invoke the local handler, if there is one.
tracepoint_reaction_starts(env, reaction, 0);
reaction_function_t handler = reaction->deadline_violation_handler;
if (handler != NULL) {
(*handler)(reaction->self);
// If the reaction produced outputs, put the resulting
// triggered reactions into the queue.
schedule_output_reactions(env, reaction, 0);
}
tracepoint_reaction_ends(env, reaction, 0);
}
}

Expand Down
2 changes: 2 additions & 0 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ void schedule_output_reactions(environment_t* env, reaction_t* reaction, int wor
violation = true;
// Invoke the local handler, if there is one.
reaction_function_t handler = downstream_to_execute_now->deadline_violation_handler;
tracepoint_reaction_starts(env, downstream_to_execute_now, worker);
if (handler != NULL) {
// Assume the mutex is still not held.
(*handler)(downstream_to_execute_now->self);
Expand All @@ -832,6 +833,7 @@ void schedule_output_reactions(environment_t* env, reaction_t* reaction, int wor
// triggered reactions into the queue or execute them directly if possible.
schedule_output_reactions(env, downstream_to_execute_now, worker);
}
tracepoint_reaction_ends(env, downstream_to_execute_now, worker);
}
}
if (!violation) {
Expand Down
2 changes: 2 additions & 0 deletions core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,7 @@ bool _lf_worker_handle_deadline_violation_for_reaction(environment_t* env, int w
tracepoint_reaction_deadline_missed(env, reaction, worker_number);
violation_occurred = true;
// Invoke the local handler, if there is one.
tracepoint_reaction_starts(env, reaction, worker_number);
reaction_function_t handler = reaction->deadline_violation_handler;
if (handler != NULL) {
LF_PRINT_LOG("Worker %d: Deadline violation. Invoking deadline handler.", worker_number);
Expand All @@ -739,6 +740,7 @@ bool _lf_worker_handle_deadline_violation_for_reaction(environment_t* env, int w
schedule_output_reactions(env, reaction, worker_number);
// Remove the reaction from the executing queue.
}
tracepoint_reaction_ends(env, reaction, worker_number);
}
}
return violation_occurred;
Expand Down
4 changes: 2 additions & 2 deletions include/core/tracepoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int register_user_trace_event(void* self, char* description);
* @param worker The thread number of the worker thread or 0 for single-threaded execution.
*/
#define tracepoint_reaction_starts(env, reaction, worker) \
call_tracepoint(reaction_starts, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, 0)
call_tracepoint(reaction_starts, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, reaction->deadline)

/**
* Trace the end of a reaction execution.
Expand All @@ -112,7 +112,7 @@ int register_user_trace_event(void* self, char* description);
* @param worker The thread number of the worker thread or 0 for single-threaded execution.
*/
#define tracepoint_reaction_ends(env, reaction, worker) \
call_tracepoint(reaction_ends, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, 0)
call_tracepoint(reaction_ends, reaction->self, env->current_tag, worker, worker, reaction->number, NULL, NULL, reaction->deadline)

/**
* Trace a call to schedule.
Expand Down
Loading