Batch 28 commit ca63702 gave RT-Thread mutex priority ceilings (1 of 3 passed), LVGL repeat cadence and RT-Thread soft-timer wakeup (0 of 3) as HARD. Each task comes from the commit Qwen measured, its digest matches, and it is still present at the batch branch head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
79 lines
3.6 KiB
C
79 lines
3.6 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "controlled.h"
|
|
|
|
static struct rt_timer timers[32];
|
|
static int ids[32], counts[32], stop_after[32];
|
|
static struct rt_spinlock *timer_lock;
|
|
static int injection_id, injection_time;
|
|
static rt_err_t peer_result;
|
|
static void fire(void *parameter)
|
|
{
|
|
int id = *(int *)parameter;
|
|
counts[id]++;
|
|
printf("F %d %lu %d\n", id, (unsigned long)rt_tick_get(), rt_thread_self() == port_worker());
|
|
if (stop_after[id] && counts[id] == stop_after[id])
|
|
printf("C %d %ld\n", id, (long)rt_timer_stop(&timers[id]));
|
|
}
|
|
static void inject_start(void *unused)
|
|
{
|
|
(void)unused;
|
|
if (injection_time >= 0) {
|
|
rt_tick_t time = (rt_tick_t)injection_time;
|
|
rt_timer_control(&timers[injection_id], RT_TIMER_CTRL_SET_TIME, &time);
|
|
}
|
|
printf("J %d %ld\n", injection_id, (long)rt_timer_start(&timers[injection_id]));
|
|
}
|
|
static void peer_resume(void *thread) { peer_result = rt_thread_resume(thread); }
|
|
int main(void)
|
|
{
|
|
char op[16];
|
|
while (scanf("%15s", op) == 1) {
|
|
int id, periodic, stop, kind;
|
|
unsigned long value;
|
|
if (!strcmp(op, "B")) {
|
|
scanf("%lu", &value); port_init((rt_tick_t)value);
|
|
ids[31] = 31;
|
|
rt_timer_init(&timers[31], "probe", fire, &ids[31], 100, RT_TIMER_FLAG_SOFT_TIMER);
|
|
port_capture_lock(); rt_timer_start(&timers[31]);
|
|
timer_lock = port_captured_lock(); rt_timer_stop(&timers[31]);
|
|
} else if (!strcmp(op, "N")) {
|
|
scanf("%d%lu%d%d", &id, &value, &periodic, &stop);
|
|
ids[id] = id; stop_after[id] = stop;
|
|
rt_timer_init(&timers[id], "client", fire, &ids[id], (rt_tick_t)value,
|
|
RT_TIMER_FLAG_SOFT_TIMER | (periodic ? RT_TIMER_FLAG_PERIODIC : 0));
|
|
} else if (!strcmp(op, "S")) {
|
|
scanf("%d", &id); printf("S %d %ld\n", id, (long)rt_timer_start(&timers[id]));
|
|
} else if (!strcmp(op, "T")) {
|
|
scanf("%d", &id); printf("T %d %ld\n", id, (long)rt_timer_stop(&timers[id]));
|
|
} else if (!strcmp(op, "U")) {
|
|
scanf("%d%lu", &id, &value); rt_tick_t time = (rt_tick_t)value;
|
|
printf("U %d %ld\n", id, (long)rt_timer_control(&timers[id], RT_TIMER_CTRL_SET_TIME, &time));
|
|
} else if (!strcmp(op, "V")) {
|
|
scanf("%d", &id); rt_uint32_t state = 0; rt_tick_t time = 0;
|
|
rt_timer_control(&timers[id], RT_TIMER_CTRL_GET_STATE, &state);
|
|
rt_timer_control(&timers[id], RT_TIMER_CTRL_GET_TIME, &time);
|
|
printf("V %d %d %lu\n", id, state == RT_TIMER_FLAG_ACTIVATED, (unsigned long)time);
|
|
} else if (!strcmp(op, "P")) port_pump();
|
|
else if (!strcmp(op, "A")) { scanf("%lu", &value); port_advance((rt_tick_t)value); }
|
|
else if (!strcmp(op, "I")) {
|
|
scanf("%d%d", &injection_id, &injection_time);
|
|
port_after_unlock(timer_lock, inject_start, NULL);
|
|
} else if (!strcmp(op, "R")) {
|
|
scanf("%d", &kind);
|
|
rt_thread_t thread = port_worker();
|
|
if (kind != 0) port_pump();
|
|
rt_err_t a, b;
|
|
if (kind == 2) {
|
|
port_before_lock(&thread->spinlock, peer_resume, thread);
|
|
a = rt_thread_resume(thread); b = peer_result;
|
|
} else { a = rt_thread_resume(thread); b = rt_thread_resume(thread); }
|
|
printf("D %ld %ld %d %d\n", (long)a, (long)b, port_ready_count(thread), port_duplicate_ready());
|
|
} else if (!strcmp(op, "Q")) {
|
|
printf("Q %d %d\n", port_duplicate_ready(), port_interleavings());
|
|
} else return 3;
|
|
}
|
|
return 0;
|
|
}
|