Exec cycle limit
This commit is contained in:
@@ -11,4 +11,5 @@ enum ExecPrompt: byte {
|
|||||||
|
|
||||||
table ExecCtrlMessage {
|
table ExecCtrlMessage {
|
||||||
prompt: ExecPrompt;
|
prompt: ExecPrompt;
|
||||||
|
tick_count: uint64 = 0; // 0 = run indefinitely, >0 = auto-pause after N ticks
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ typedef struct {
|
|||||||
uint8_t* resetRequest;
|
uint8_t* resetRequest;
|
||||||
uint8_t* emulState;
|
uint8_t* emulState;
|
||||||
uint64_t* clockCounter;
|
uint64_t* clockCounter;
|
||||||
|
uint64_t* tickTarget; // 0 = run indefinitely, >0 = auto-pause at this tick
|
||||||
LinkedListEntry** clientsHead;
|
LinkedListEntry** clientsHead;
|
||||||
uint8_t* utilizedFlag;
|
uint8_t* utilizedFlag;
|
||||||
OutgoingBuffers* outBufs;
|
OutgoingBuffers* outBufs;
|
||||||
|
|||||||
11
src/main.c
11
src/main.c
@@ -480,6 +480,7 @@ int main(int argc, char** argv)
|
|||||||
LinkedListEntry* clientsLinkedListHead = NULL;
|
LinkedListEntry* clientsLinkedListHead = NULL;
|
||||||
|
|
||||||
uint64_t clockCounter = 0;
|
uint64_t clockCounter = 0;
|
||||||
|
uint64_t tickTarget = 0;
|
||||||
uint8_t resetRequest = 0;
|
uint8_t resetRequest = 0;
|
||||||
|
|
||||||
uint8_t utilizedFlag = 0;
|
uint8_t utilizedFlag = 0;
|
||||||
@@ -487,6 +488,7 @@ int main(int argc, char** argv)
|
|||||||
&resetRequest,
|
&resetRequest,
|
||||||
&emulState,
|
&emulState,
|
||||||
&clockCounter,
|
&clockCounter,
|
||||||
|
&tickTarget,
|
||||||
&clientsLinkedListHead,
|
&clientsLinkedListHead,
|
||||||
&utilizedFlag,
|
&utilizedFlag,
|
||||||
&outBufs,
|
&outBufs,
|
||||||
@@ -746,6 +748,15 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
clockCounter++;
|
clockCounter++;
|
||||||
|
|
||||||
|
if(tickTarget > 0 && clockCounter >= tickTarget)
|
||||||
|
{
|
||||||
|
tickTarget = 0;
|
||||||
|
emulState = EMUL_STATE_PAUSE;
|
||||||
|
size_t notify_len;
|
||||||
|
uint8_t* notify_msg = fb_build_exec_notify(0, clockCounter, EMUL_STATE_PAUSE, ¬ify_len);
|
||||||
|
broadcastClients(&emulContext, notify_msg, notify_len);
|
||||||
|
}
|
||||||
|
|
||||||
if(emulContext.simRateLimit > 0)
|
if(emulContext.simRateLimit > 0)
|
||||||
{
|
{
|
||||||
lastTickAt = getCurrentUsec();
|
lastTickAt = getCurrentUsec();
|
||||||
|
|||||||
@@ -51,8 +51,11 @@ void handleIncomingCtrlMessage(
|
|||||||
|
|
||||||
hmmmm_ctrl_exec_ExecPrompt_enum_t prompt =
|
hmmmm_ctrl_exec_ExecPrompt_enum_t prompt =
|
||||||
hmmmm_ctrl_exec_ExecCtrlMessage_prompt(exec);
|
hmmmm_ctrl_exec_ExecCtrlMessage_prompt(exec);
|
||||||
|
uint64_t tick_count =
|
||||||
|
hmmmm_ctrl_exec_ExecCtrlMessage_tick_count(exec);
|
||||||
|
|
||||||
printf("[CTRL/EXEC] prompt=%s\n", hmmmm_ctrl_exec_ExecPrompt_name(prompt));
|
printf("[CTRL/EXEC] prompt=%s tick_count=%lu\n",
|
||||||
|
hmmmm_ctrl_exec_ExecPrompt_name(prompt), tick_count);
|
||||||
|
|
||||||
uint8_t state_op = prompt_to_state_op(prompt);
|
uint8_t state_op = prompt_to_state_op(prompt);
|
||||||
if (state_op == 0) {
|
if (state_op == 0) {
|
||||||
@@ -69,6 +72,12 @@ void handleIncomingCtrlMessage(
|
|||||||
*emulContext->emulState = new_state;
|
*emulContext->emulState = new_state;
|
||||||
printf("[CTRL/EXEC] state -> %u\n", new_state);
|
printf("[CTRL/EXEC] state -> %u\n", new_state);
|
||||||
|
|
||||||
|
if (new_state == EMUL_STATE_EXEC && tick_count > 0) {
|
||||||
|
*emulContext->tickTarget = *emulContext->clockCounter + tick_count;
|
||||||
|
} else if (new_state == EMUL_STATE_EXEC) {
|
||||||
|
*emulContext->tickTarget = 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t msg_len;
|
size_t msg_len;
|
||||||
uint8_t* out = fb_build_exec_notify(0, *emulContext->clockCounter, new_state, &msg_len);
|
uint8_t* out = fb_build_exec_notify(0, *emulContext->clockCounter, new_state, &msg_len);
|
||||||
broadcastClients(emulContext, out, msg_len);
|
broadcastClients(emulContext, out, msg_len);
|
||||||
|
|||||||
Reference in New Issue
Block a user