From fecb86f6093c1e8aed6ab05c29c5af9d0cb93157 Mon Sep 17 00:00:00 2001 From: Kimplul Date: Tue, 24 Sep 2024 16:51:51 +0300 Subject: initial work towards message passing interface + As they are currently implemented, grid *may* get stuck if two nodes try to send to eachother at the same time, I should probably add in some kind of input buffer as well --- src/clock_domain.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/clock_domain.c') diff --git a/src/clock_domain.c b/src/clock_domain.c index 6610d8f..74f0f03 100644 --- a/src/clock_domain.c +++ b/src/clock_domain.c @@ -20,8 +20,6 @@ struct clock_domain { tick period; stat ret; - - mtx_t mtx; }; void advance_clock(struct clock_domain *clk) @@ -41,7 +39,6 @@ struct clock_domain *create_clock_domain(tick period) return NULL; clk->period = period; - mtx_init(&clk->mtx, mtx_plain); clk->components = vec_create(sizeof(struct component *)); return clk; @@ -62,20 +59,12 @@ stat clock_domain_add(struct clock_domain *clk, struct component *component) return OK; } -static void update_ret(struct clock_domain *clk, stat ret) -{ - if (ret) { - mtx_lock(&clk->mtx); - clk->ret = ret; - mtx_unlock(&clk->mtx); - } -} - static void clocked_component_tick(struct clock_domain *clk, struct component *component) { - stat ret = component->clock(component); - update_ret(clk, ret); + stat r = component->clock(component); + if (r) + clk->ret = r; } stat clock_domain_tick(struct clock_domain *clk) -- cgit v1.3