Panic on events when the thread is preempted
When the thread is not running on the CPU it shouldn't be able to emit events. A new emulation test ensures the emulation fails if it happens.
This commit is contained in:
parent
31fa1508f7
commit
6aff4388eb
@ -555,6 +555,11 @@ process_ev(struct emu *emu)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (emu->thread->is_out_of_cpu) {
|
||||
err("current thread %d out of CPU", emu->thread->tid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (emu->ev->c) {
|
||||
case 'S':
|
||||
case 'U':
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2021-2023 Barcelona Supercomputing Center (BSC)
|
||||
/* Copyright (c) 2021-2024 Barcelona Supercomputing Center (BSC)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include "ovni_priv.h"
|
||||
@ -458,6 +458,11 @@ model_ovni_event(struct emu *emu)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (emu->thread->is_out_of_cpu) {
|
||||
err("current thread %d out of CPU", emu->thread->tid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (emu->ev->c) {
|
||||
case 'H':
|
||||
return pre_thread(emu);
|
||||
|
18
test/emu/kernel/instr_kernel.h
Normal file
18
test/emu/kernel/instr_kernel.h
Normal file
@ -0,0 +1,18 @@
|
||||
/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#ifndef INSTR_KERNEL_H
|
||||
#define INSTR_KERNEL_H
|
||||
|
||||
#include "instr.h"
|
||||
|
||||
static inline void
|
||||
instr_kernel_init(void)
|
||||
{
|
||||
instr_require("kernel");
|
||||
}
|
||||
|
||||
INSTR_0ARG(instr_kernel_cs_out, "KCO")
|
||||
INSTR_0ARG(instr_kernel_cs_in, "KCI")
|
||||
|
||||
#endif /* INSTR_KERNEL_H */
|
@ -31,3 +31,6 @@ test_emu(bad-pause-parallel.c SHOULD_FAIL
|
||||
REGEX "body_pause: body(id=1,taskid=1) is not allowed to pause")
|
||||
test_emu(bad-nest-from-parallel.c SHOULD_FAIL
|
||||
REGEX "body_execute: cannot nest body(id=2,taskid=2) over body(id=1,taskid=1) which is already running")
|
||||
|
||||
test_emu(events-from-outside-cpu.c SHOULD_FAIL
|
||||
REGEX "current thread .* out of CPU")
|
||||
|
24
test/emu/nosv/events-from-outside-cpu.c
Normal file
24
test/emu/nosv/events-from-outside-cpu.c
Normal file
@ -0,0 +1,24 @@
|
||||
/* Copyright (c) 2024 Barcelona Supercomputing Center (BSC)
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later */
|
||||
|
||||
#include <ovni.h>
|
||||
#include "instr_nosv.h"
|
||||
#include "../kernel/instr_kernel.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
instr_start(0, 1);
|
||||
instr_nosv_init();
|
||||
instr_kernel_init();
|
||||
|
||||
/* Make the current thread out of CPU */
|
||||
instr_kernel_cs_out();
|
||||
|
||||
/* Try to emit a nOS-V event: should fail */
|
||||
instr_nosv_type_create(666);
|
||||
|
||||
instr_end();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user