From 8da034276072addcba7299142fa55b0550fcb2e8 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Mon, 13 Mar 2023 17:17:14 +0100 Subject: [PATCH] Set thread and CPU channels to ignore duplicates Some of the PRV channels no longer need to skip duplicates. --- src/emu/cpu.c | 19 +++++++++---------- src/emu/thread.c | 11 ++++++++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/emu/cpu.c b/src/emu/cpu.c index e06d76e..8c5b3f4 100644 --- a/src/emu/cpu.c +++ b/src/emu/cpu.c @@ -27,10 +27,8 @@ static int chan_type[] = { [CPU_CHAN_THACT] = -1, }; -static long chan_flags[] = { - [CPU_CHAN_PID] = PRV_SKIPDUP, - [CPU_CHAN_TID] = PRV_SKIPDUP, - [CPU_CHAN_NRUN] = PRV_SKIPDUP | PRV_ZERO, +static long prv_flags[] = { + [CPU_CHAN_NRUN] = PRV_ZERO, }; void @@ -116,11 +114,12 @@ cpu_init_end(struct cpu *cpu) chan_fmt, cpu->gindex, chan_name[i]); } - chan_prop_set(&cpu->chan[CPU_CHAN_NRUN], CHAN_ALLOW_DUP, 1); - chan_prop_set(&cpu->chan[CPU_CHAN_TID], CHAN_ALLOW_DUP, 1); - chan_prop_set(&cpu->chan[CPU_CHAN_PID], CHAN_ALLOW_DUP, 1); - chan_prop_set(&cpu->chan[CPU_CHAN_THRUN], CHAN_ALLOW_DUP, 1); - chan_prop_set(&cpu->chan[CPU_CHAN_THACT], CHAN_ALLOW_DUP, 1); + /* Duplicates may be written when a thread changes the state */ + chan_prop_set(&cpu->chan[CPU_CHAN_NRUN], CHAN_IGNORE_DUP, 1); + chan_prop_set(&cpu->chan[CPU_CHAN_TID], CHAN_IGNORE_DUP, 1); + chan_prop_set(&cpu->chan[CPU_CHAN_PID], CHAN_IGNORE_DUP, 1); + chan_prop_set(&cpu->chan[CPU_CHAN_THRUN], CHAN_IGNORE_DUP, 1); + chan_prop_set(&cpu->chan[CPU_CHAN_THACT], CHAN_IGNORE_DUP, 1); cpu->is_init = 1; @@ -155,7 +154,7 @@ cpu_connect(struct cpu *cpu, struct bay *bay, struct recorder *rec) continue; long row = cpu->gindex; - long flags = chan_flags[i]; + long flags = prv_flags[i]; if (prv_register(prv, row, type, bay, c, flags)) { err("prv_register failed"); return -1; diff --git a/src/emu/thread.c b/src/emu/thread.c index 44fc37a..0969f48 100644 --- a/src/emu/thread.c +++ b/src/emu/thread.c @@ -22,8 +22,11 @@ static const int chan_type[] = { }; static const long prv_flags[] = { - [TH_CHAN_CPU] = PRV_SKIPDUP | PRV_NEXT, /* Add one to the cpu gindex */ - [TH_CHAN_TID] = PRV_SKIPDUP, + /* Add one to the zero-based cpu gindex */ + [TH_CHAN_CPU] = PRV_NEXT, + + /* FIXME: Only needed for delayed connect, as the state channel is used + * as select in the muxes, which is set to dirty when connecting it. */ [TH_CHAN_STATE] = PRV_SKIPDUP, }; @@ -144,7 +147,9 @@ thread_init_end(struct thread *th) chan_fmt, th->gindex, chan_name[i]); } - chan_prop_set(&th->chan[TH_CHAN_TID], CHAN_ALLOW_DUP, 1); + /* The transition Running -> Cooling causes a duplicate (the thread is + * still active) */ + chan_prop_set(&th->chan[TH_CHAN_TID], CHAN_IGNORE_DUP, 1); th->is_init = 1; return 0;