Check correct thread state at finalization

Prevents external threads from being left in Running state when they
finish, causing the virtual CPU to be always occupied with at least one
thread. This situation causes the virtual CPU to never report any
subsystem.
This commit is contained in:
Rodrigo Arias 2023-02-20 18:43:20 +01:00 committed by Rodrigo Arias Mallo
parent 9407616c2b
commit a1cc8ba87c
4 changed files with 24 additions and 0 deletions

View File

@ -45,6 +45,7 @@ add_library(emu STATIC
ovni/probe.c ovni/probe.c
ovni/create.c ovni/create.c
ovni/event.c ovni/event.c
ovni/finish.c
nanos6/setup.c nanos6/setup.c
nanos6/event.c nanos6/event.c
nosv/setup.c nosv/setup.c

21
src/emu/ovni/finish.c Normal file
View File

@ -0,0 +1,21 @@
/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
* SPDX-License-Identifier: GPL-3.0-or-later */
#include "ovni_priv.h"
int
ovni_finish(struct emu *emu)
{
struct system *sys = &emu->system;
int ret = 0;
/* Ensure that all threads are in the Dead state */
for (struct thread *t = sys->threads; t; t = t->gnext) {
if (t->state != TH_ST_DEAD) {
err("thread %d is not dead (%s)", t->tid, t->id);
ret = -1;
}
}
return ret;
}

View File

@ -38,5 +38,6 @@ struct ovni_cpu {
int ovni_probe(struct emu *emu); int ovni_probe(struct emu *emu);
int ovni_create(struct emu *emu); int ovni_create(struct emu *emu);
int ovni_event(struct emu *emu); int ovni_event(struct emu *emu);
int ovni_finish(struct emu *emu);
#endif /* OVNI_PRIV_H */ #endif /* OVNI_PRIV_H */

View File

@ -10,6 +10,7 @@ struct model_spec model_ovni = {
.connect = NULL, .connect = NULL,
.event = ovni_event, .event = ovni_event,
.probe = ovni_probe, .probe = ovni_probe,
.finish = ovni_finish,
}; };
int int