reactor-c
C Runtime for Lingua Franca
|
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 "scheduler_instance.h"
#include "scheduler_sync_tag_advance.h"
#include "scheduler.h"
#include "lf_semaphore.h"
#include "tracepoint.h"
#include "util.h"
#include "reactor_threaded.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. | |
Non-preemptive scheduler for the threaded runtime of the C target of Lingua Franca.
#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'.
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).
worker_number |
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'.
This scheduler ignores the worker number.
The scheduler will ensure that the same reaction is not triggered twice in the same tag.
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). |