From 576936ef016e8deade4315f68cc9c3da80fe64a6 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Tue, 6 Sep 2022 10:28:55 +0200 Subject: [PATCH] Add CPU idle and active events --- doc/emulation/events.md | 3 +++ emu.h | 8 +++++--- emu_nanos6.c | 21 ++++++++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/doc/emulation/events.md b/doc/emulation/events.md index 05e70cd..31507ba 100644 --- a/doc/emulation/events.md +++ b/doc/emulation/events.md @@ -187,4 +187,7 @@ KCI Is back in the CPU due to a context switch 6HL Unsets itself as leader thread 6Hm Sets itself as main thread 6HM Unsets itself as main thread + +6Ci CPU becomes idle +6Ca CPU becomes active ``` diff --git a/emu.h b/emu.h index 0ba55b8..fe50ce3 100644 --- a/emu.h +++ b/emu.h @@ -118,10 +118,12 @@ enum nanos6_ss_state { ST_NANOS6_HANDLING_TASK, ST_NANOS6_WORKER_LOOP, - /* Value 51 is broken in old Paraver */ + /* Value 51 is broken in old Paraver */ EV_NANOS6_SCHED_RECV = 60, - EV_NANOS6_SCHED_SEND = 61, - EV_NANOS6_SCHED_SELF = 62, + EV_NANOS6_SCHED_SEND, + EV_NANOS6_SCHED_SELF, + EV_NANOS6_CPU_IDLE, + EV_NANOS6_CPU_ACTIVE, }; enum nanos6_thread_type { diff --git a/emu_nanos6.c b/emu_nanos6.c index 4375040..0041ca1 100644 --- a/emu_nanos6.c +++ b/emu_nanos6.c @@ -379,7 +379,6 @@ pre_worker(struct ovni_emu *emu) } } - static void pre_sched(struct ovni_emu *emu) { @@ -427,6 +426,25 @@ pre_thread(struct ovni_emu *emu) } } +static void +pre_cpu(struct ovni_emu *emu) +{ + struct ovni_ethread *th; + struct ovni_chan *chan_th; + + th = emu->cur_thread; + chan_th = &th->chan[CHAN_NANOS6_SUBSYSTEM]; + + switch(emu->cur_ev->header.value) + { + case 'i': chan_ev(chan_th, EV_NANOS6_CPU_IDLE); break; + case 'a': chan_ev(chan_th, EV_NANOS6_CPU_ACTIVE); break; + default: + die("unknown Nanos6 cpu event %c\n", + emu->cur_ev->header.value); + } +} + static void pre_ss(struct ovni_emu *emu, int st) { @@ -487,6 +505,7 @@ hook_pre_nanos6(struct ovni_emu *emu) case 'D': pre_deps(emu); break; case 'B': pre_blocking(emu); break; case 'W': pre_worker(emu); break; + case 'C': pre_cpu(emu); break; default: die("unknown Nanos6 event category %c\n", emu->cur_ev->header.category);