reactor-c
C Runtime for Lingua Franca
|
Global Earliest Deadline First (GEDF) non-preemptive scheduler for the threaded runtime of the C target of Lingua Franca. More...
#include "lf_types.h"
#include <assert.h>
#include "low_level_platform.h"
#include "environment.h"
#include "pqueue.h"
#include "reactor_threaded.h"
#include "scheduler_instance.h"
#include "scheduler_sync_tag_advance.h"
#include "scheduler.h"
#include "tracepoint.h"
#include "util.h"
Data Structures | |
struct | custom_scheduler_data_t |
Macros | |
#define | NUMBER_OF_WORKERS 1 |
Typedefs | |
typedef struct custom_scheduler_data_t | custom_scheduler_data_t |
Functions | |
void | lf_sched_init (environment_t *env, size_t number_of_workers, sched_params_t *params) |
Initialize the scheduler. | |
void | lf_sched_free (lf_scheduler_t *scheduler) |
Free the memory used by the scheduler. | |
reaction_t * | lf_sched_get_ready_reaction (lf_scheduler_t *scheduler, int worker_number) |
Ask the scheduler for one more reaction. | |
void | lf_sched_done_with_reaction (size_t worker_number, reaction_t *done_reaction) |
Inform the scheduler that worker thread 'worker_number' is done executing the 'done_reaction'. | |
void | lf_scheduler_trigger_reaction (lf_scheduler_t *scheduler, reaction_t *reaction, int worker_number) |
Inform the scheduler that worker thread 'worker_number' would like to trigger 'reaction' at the current tag. | |
Global Earliest Deadline First (GEDF) non-preemptive scheduler for the threaded runtime of the C target of Lingua Franca.
At each tag, this scheduler prioritizes reactions with the smallest (inferred) deadline. An inferred deadline for reaction R is either an explicitly declared deadline or the declared deadline of a reaction that depends on R. This scheduler is non-preemptive, meaning that once a worker thread starts executing a reaction, it will execute that reaction to completion. The underlying thread scheduler, of course, could preempt the execution in favor of some other worker thread. This scheduler does not take into account execution times of reactions. Moreover, it does not prioritize reactions across distinct tags.
#define NUMBER_OF_WORKERS 1 |
typedef struct custom_scheduler_data_t custom_scheduler_data_t |
void lf_sched_done_with_reaction | ( | size_t | worker_number, |
reaction_t * | done_reaction ) |
Inform the scheduler that worker thread 'worker_number' is done executing the 'done_reaction'.
scheduler | The scheduler |
worker_number | The worker number for the worker thread that has finished executing 'done_reaction'. |
done_reaction | The reaction that is done. |
void lf_sched_free | ( | lf_scheduler_t * | scheduler | ) |
Free the memory used by the scheduler.
This must be called when the scheduler is no longer needed.
reaction_t * lf_sched_get_ready_reaction | ( | lf_scheduler_t * | scheduler, |
int | worker_number ) |
Ask the scheduler for one more reaction.
This function blocks until it can return a ready reaction for worker thread 'worker_number' or it is time for the worker thread to stop and exit (where a NULL value would be returned). This function assumes that the environment mutex is not locked.
scheduler | The scheduler |
worker_number | For the calling worker thread. |
void lf_sched_init | ( | environment_t * | env, |
size_t | number_of_workers, | ||
sched_params_t * | params ) |
Initialize the scheduler.
This has to be called before other functions of the scheduler can be used. If the scheduler is already initialized, this will be a no-op.
env | Environment within which we are executing. |
number_of_workers | Indicate how many workers this scheduler will be managing. |
option | Pointer to a sched_params_t struct containing additional scheduler parameters. |
void lf_scheduler_trigger_reaction | ( | lf_scheduler_t * | scheduler, |
reaction_t * | reaction, | ||
int | worker_number ) |
Inform the scheduler that worker thread 'worker_number' would like to trigger 'reaction' at the current tag.
If a worker number is not available (e.g., this function is not called by a worker thread), -1 should be passed as the 'worker_number'.
The scheduler will ensure that the same reaction is not triggered twice in the same tag.
scheduler | The scheduler |
reaction | The reaction to trigger at the current tag. |
worker_number | The ID of the worker that is making this call. 0 should be used if there is only one worker (e.g., when the program is using the single-threaded C runtime). -1 is used for an anonymous call in a context where a worker number does not make sense (e.g., the caller is not a worker thread). |