-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3aa9412
commit 27a5ec5
Showing
23 changed files
with
1,027 additions
and
396 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Created by tanneberger on 11/16/24. | ||
// | ||
|
||
#ifndef SCHEDULER_H | ||
#define SCHEDULER_H | ||
#include "reactor-uc/error.h" | ||
#include "reactor-uc/queues.h" | ||
#include "reactor-uc/scheduler.h" | ||
|
||
typedef struct DynamicScheduler DynamicScheduler; | ||
typedef struct Environment Environment; | ||
|
||
struct DynamicScheduler { | ||
Scheduler scheduler; | ||
Environment *env; | ||
EventQueue event_queue; | ||
ReactionQueue reaction_queue; | ||
// The following two fields are used to implement a linked list of Triggers | ||
// that are registered for cleanup at the end of the current tag. | ||
Trigger *cleanup_ll_head; | ||
Trigger *cleanup_ll_tail; | ||
bool leader; // Whether this scheduler is the leader in a federated program and selects the start tag. | ||
instant_t start_time; // The physical time at which the program started. | ||
interval_t duration; // The duration after which the program should stop. | ||
tag_t stop_tag; // The tag at which the program should stop. This is set by the user or by the scheduler. | ||
tag_t current_tag; // The current logical tag. Set by the scheduler and read by user in the reaction bodies. | ||
bool keep_alive; // Whether the program should keep running even if there are no more events to process. | ||
}; | ||
|
||
void DynamicScheduler_ctor(DynamicScheduler *self, Environment *env); | ||
|
||
#endif //SCHEDULER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#ifndef SCHEDULER_STATIC_FUNCTION_H | ||
#define SCHEDULER_STATIC_FUNCTION_H | ||
|
||
#include "scheduler_instructions.h" | ||
#include "reactor-uc/reaction.h" | ||
#include "reactor-uc/platform.h" | ||
|
||
/** | ||
* @brief Function type with a void* argument. To make this type represent a | ||
* generic function, one can write a wrapper function around the target function | ||
* and use the first argument as a pointer to a struct of input arguments | ||
* and return values. | ||
*/ | ||
|
||
#ifndef LF_PRINT_DEBUG | ||
#define LF_PRINT_DEBUG(A, ...) {}; | ||
#endif | ||
|
||
/** | ||
* @brief Wrapper function for peeking a priority queue. | ||
*/ | ||
void push_pop_peek_pqueue(void *self); | ||
|
||
void execute_inst_ADD(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_ADDI(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_BEQ(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_BGE(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_BLT(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_BNE(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_DU(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_EXE(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_WLT(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_WU(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_JAL(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_JALR(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
void execute_inst_STP(Platform* platform, size_t worker_number, operand_t op1, operand_t op2, | ||
operand_t op3, bool debug, size_t *pc, | ||
Reaction **returned_reaction, bool *exit_loop); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// Created by tanneberger on 11/16/24. | ||
// | ||
|
||
#ifndef STATIC_SCHEDULER_H | ||
#define STATIC_SCHEDULER_H | ||
#include "reactor-uc/error.h" | ||
#include "reactor-uc/queues.h" | ||
#include "reactor-uc/scheduler.h" | ||
|
||
typedef struct StaticScheduler StaticScheduler; | ||
typedef struct Environment Environment; | ||
|
||
struct StaticScheduler { | ||
Scheduler* scheduler; | ||
Environment *env; | ||
const inst_t** static_schedule; | ||
size_t* pc; | ||
}; | ||
|
||
void StaticScheduler_ctor(StaticScheduler *self, Environment *env); | ||
|
||
#endif //STATIC_SCHEDULER_H |
72 changes: 72 additions & 0 deletions
72
include/reactor-uc/schedulers/static/scheduler_instructions.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @author Shaokai Lin <[email protected]> | ||
* @brief Format of the instruction set | ||
*/ | ||
#ifndef SCHEDULER_INSTRUCTIONS_H | ||
#define SCHEDULER_INSTRUCTIONS_H | ||
|
||
#include "reactor-uc/reaction.h" | ||
#include "reactor-uc/platform.h" | ||
|
||
typedef enum { | ||
ADD, | ||
ADDI, | ||
ADV, | ||
ADVI, | ||
BEQ, | ||
BGE, | ||
BLT, | ||
BNE, | ||
DU, | ||
EXE, | ||
JAL, | ||
JALR, | ||
STP, | ||
WLT, | ||
WU, | ||
} opcode_t; | ||
|
||
/** | ||
* @brief Convenient typedefs for the data types used by the C implementation of | ||
* PRET VM. A register is 64bits and an immediate is 64bits. This avoids any | ||
* issue with time and overflow. Arguably it is worth it even for smaller | ||
* platforms. | ||
* | ||
*/ | ||
typedef volatile uint64_t reg_t; | ||
typedef uint64_t imm_t; | ||
|
||
/** | ||
* @brief An union representing a single operand for the PRET VM. A union | ||
* means that we have one piece of memory, which is big enough to fit either | ||
* one of the two members of the union. | ||
* | ||
*/ | ||
typedef union { | ||
reg_t *reg; | ||
imm_t imm; | ||
} operand_t; | ||
|
||
/** | ||
* @brief Virtual instruction function pointer | ||
*/ | ||
typedef void (*function_virtual_instruction_t)( | ||
Platform* platform, size_t worker_number, operand_t op1, operand_t op2, operand_t op3, | ||
bool debug, size_t *pc, Reaction **returned_reaction, bool *exit_loop); | ||
|
||
/** | ||
* @brief This struct represents a PRET VM instruction for C platforms. | ||
* There is an opcode and three operands. The operands are unions so they | ||
* can be either a pointer or an immediate | ||
* | ||
*/ | ||
typedef struct inst_t { | ||
function_virtual_instruction_t func; | ||
opcode_t opcode; | ||
operand_t op1; | ||
operand_t op2; | ||
operand_t op3; | ||
bool debug; | ||
} inst_t; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.