Mark threads out of CPU by kernel events

This commit is contained in:
Rodrigo Arias 2024-03-20 15:50:46 +01:00
parent d1312ff6e9
commit 31fa1508f7
2 changed files with 7 additions and 2 deletions

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#include "kernel_priv.h" #include "kernel_priv.h"
@ -19,8 +19,10 @@ context_switch(struct emu *emu)
switch (emu->ev->v) { switch (emu->ev->v) {
case 'O': case 'O':
emu->thread->is_out_of_cpu = 1;
return chan_push(ch, value_int64(ST_CSOUT)); return chan_push(ch, value_int64(ST_CSOUT));
case 'I': case 'I':
emu->thread->is_out_of_cpu = 0;
return chan_pop(ch, value_int64(ST_CSOUT)); return chan_pop(ch, value_int64(ST_CSOUT));
default: default:
err("unknown context switch event"); err("unknown context switch event");

View File

@ -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 */ * SPDX-License-Identifier: GPL-3.0-or-later */
#ifndef THREAD_H #ifndef THREAD_H
@ -54,6 +54,9 @@ struct thread {
int is_running; int is_running;
int is_active; int is_active;
/* Out of CPU as informed by the kernel */
int is_out_of_cpu;
/* Current cpu, NULL if not unique affinity */ /* Current cpu, NULL if not unique affinity */
struct cpu *cpu; struct cpu *cpu;