2021-10-26 18:42:41 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021 Barcelona Supercomputing Center (BSC)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-08-02 10:08:58 +02:00
|
|
|
#include <assert.h>
|
|
|
|
#include "uthash.h"
|
|
|
|
|
2021-07-28 11:56:35 +02:00
|
|
|
#include "ovni.h"
|
|
|
|
#include "emu.h"
|
2021-08-02 10:08:58 +02:00
|
|
|
#include "prv.h"
|
2021-10-21 16:15:29 +02:00
|
|
|
#include "chan.h"
|
2021-07-28 11:56:35 +02:00
|
|
|
|
2021-10-21 16:15:29 +02:00
|
|
|
/* --------------------------- init ------------------------------- */
|
|
|
|
|
|
|
|
void
|
2021-10-21 16:46:42 +02:00
|
|
|
hook_init_nosv(struct ovni_emu *emu)
|
2021-10-21 16:15:29 +02:00
|
|
|
{
|
|
|
|
struct ovni_ethread *th;
|
2021-10-21 16:46:42 +02:00
|
|
|
struct ovni_cpu *cpu;
|
2021-10-18 12:47:51 +02:00
|
|
|
struct ovni_chan **uth, **ucpu;
|
|
|
|
size_t i;
|
|
|
|
int row;
|
2021-10-21 16:46:42 +02:00
|
|
|
FILE *prv_th, *prv_cpu;
|
2021-10-21 16:15:29 +02:00
|
|
|
int64_t *clock;
|
|
|
|
|
2021-10-21 16:46:42 +02:00
|
|
|
clock = &emu->delta_time;
|
|
|
|
prv_th = emu->prv_thread;
|
|
|
|
prv_cpu = emu->prv_cpu;
|
|
|
|
|
|
|
|
/* Init the channels in all threads */
|
2021-10-21 16:15:29 +02:00
|
|
|
for(i=0; i<emu->total_nthreads; i++)
|
|
|
|
{
|
|
|
|
th = emu->global_thread[i];
|
|
|
|
row = th->gindex + 1;
|
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
uth = &emu->th_chan;
|
2021-10-21 16:46:42 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
chan_th_init(th, uth, CHAN_NOSV_TASKID, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock);
|
|
|
|
chan_th_init(th, uth, CHAN_NOSV_TYPEID, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock);
|
|
|
|
chan_th_init(th, uth, CHAN_NOSV_APPID, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_th, clock);
|
2021-10-11 11:12:26 +02:00
|
|
|
|
|
|
|
/* We allow threads to emit subsystem events in cooling and
|
|
|
|
* warming states as well, as they may be allocating memory.
|
|
|
|
* However, these information won't be presented in the CPU
|
|
|
|
* channel, as it only shows the thread in the running state */
|
2021-10-18 12:47:51 +02:00
|
|
|
chan_th_init(th, uth, CHAN_NOSV_SUBSYSTEM, CHAN_TRACK_TH_ACTIVE, 0, 0, 1, row, prv_th, clock);
|
2021-10-21 16:46:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init the nosv channels in all cpus */
|
|
|
|
for(i=0; i<emu->total_ncpus; i++)
|
|
|
|
{
|
|
|
|
cpu = emu->global_cpu[i];
|
|
|
|
row = cpu->gindex + 1;
|
2021-10-18 12:47:51 +02:00
|
|
|
ucpu = &emu->cpu_chan;
|
|
|
|
|
2021-10-21 15:46:32 +02:00
|
|
|
chan_cpu_init(cpu, ucpu, CHAN_NOSV_TASKID, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_cpu, clock);
|
2021-11-17 12:11:13 +01:00
|
|
|
chan_cpu_init(cpu, ucpu, CHAN_NOSV_TYPEID, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_cpu, clock);
|
|
|
|
chan_cpu_init(cpu, ucpu, CHAN_NOSV_APPID, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_cpu, clock);
|
|
|
|
chan_cpu_init(cpu, ucpu, CHAN_NOSV_SUBSYSTEM, CHAN_TRACK_TH_RUNNING, 0, 0, 1, row, prv_cpu, clock);
|
2021-10-21 16:15:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-29 18:13:41 +02:00
|
|
|
/* --------------------------- pre ------------------------------- */
|
|
|
|
|
2021-07-29 17:46:25 +02:00
|
|
|
static void
|
|
|
|
pre_task_create(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct nosv_task *task, *p = NULL;
|
|
|
|
|
2021-07-29 18:13:41 +02:00
|
|
|
task = calloc(1, sizeof(*task));
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
if(task == NULL)
|
|
|
|
{
|
2021-07-29 18:13:41 +02:00
|
|
|
perror("calloc");
|
2021-07-29 17:46:25 +02:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
task->id = emu->cur_ev->payload.i32[0];
|
2021-07-29 18:13:41 +02:00
|
|
|
task->type_id = emu->cur_ev->payload.i32[1];
|
2021-07-29 17:46:25 +02:00
|
|
|
task->state = TASK_ST_CREATED;
|
|
|
|
|
|
|
|
/* Ensure the task id is new */
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_FIND_INT(emu->cur_proc->tasks, &task->id, p);
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
if(p != NULL)
|
|
|
|
{
|
2021-07-29 18:13:41 +02:00
|
|
|
err("A task with id %d already exists\n", p->id);
|
2021-07-29 17:46:25 +02:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add the new task to the hash table */
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_ADD_INT(emu->cur_proc->tasks, id, task);
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
emu->cur_task = task;
|
|
|
|
|
|
|
|
dbg("new task created id=%d\n", task->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pre_task_execute(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct nosv_task *task;
|
|
|
|
int taskid;
|
|
|
|
|
|
|
|
taskid = emu->cur_ev->payload.i32[0];
|
|
|
|
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_FIND_INT(emu->cur_proc->tasks, &taskid, task);
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
assert(task != NULL);
|
|
|
|
assert(emu->cur_thread->state == TH_ST_RUNNING);
|
|
|
|
assert(emu->cur_thread->task == NULL);
|
|
|
|
|
|
|
|
task->state = TASK_ST_RUNNING;
|
|
|
|
task->thread = emu->cur_thread;
|
|
|
|
emu->cur_thread->task = task;
|
|
|
|
|
|
|
|
emu->cur_task = task;
|
|
|
|
|
|
|
|
dbg("task id=%d runs now\n", task->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pre_task_pause(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct nosv_task *task;
|
|
|
|
int taskid;
|
|
|
|
|
|
|
|
taskid = emu->cur_ev->payload.i32[0];
|
|
|
|
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_FIND_INT(emu->cur_proc->tasks, &taskid, task);
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
assert(task != NULL);
|
|
|
|
assert(task->state == TASK_ST_RUNNING);
|
|
|
|
assert(emu->cur_thread->state == TH_ST_RUNNING);
|
|
|
|
assert(emu->cur_thread->task == task);
|
|
|
|
assert(emu->cur_thread == task->thread);
|
|
|
|
|
|
|
|
task->state = TASK_ST_PAUSED;
|
|
|
|
|
|
|
|
emu->cur_task = task;
|
|
|
|
|
|
|
|
dbg("task id=%d pauses\n", task->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pre_task_resume(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct nosv_task *task;
|
|
|
|
int taskid;
|
|
|
|
|
|
|
|
taskid = emu->cur_ev->payload.i32[0];
|
|
|
|
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_FIND_INT(emu->cur_proc->tasks, &taskid, task);
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
assert(task != NULL);
|
|
|
|
assert(task->state == TASK_ST_PAUSED);
|
|
|
|
assert(emu->cur_thread->state == TH_ST_RUNNING);
|
|
|
|
assert(emu->cur_thread->task == task);
|
|
|
|
assert(emu->cur_thread == task->thread);
|
|
|
|
|
|
|
|
task->state = TASK_ST_RUNNING;
|
|
|
|
|
|
|
|
emu->cur_task = task;
|
|
|
|
|
|
|
|
dbg("task id=%d resumes\n", task->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
pre_task_end(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct nosv_task *task;
|
|
|
|
int taskid;
|
|
|
|
|
|
|
|
taskid = emu->cur_ev->payload.i32[0];
|
|
|
|
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_FIND_INT(emu->cur_proc->tasks, &taskid, task);
|
2021-07-29 17:46:25 +02:00
|
|
|
|
|
|
|
assert(task != NULL);
|
|
|
|
assert(task->state == TASK_ST_RUNNING);
|
|
|
|
assert(emu->cur_thread->state == TH_ST_RUNNING);
|
|
|
|
assert(emu->cur_thread->task == task);
|
|
|
|
assert(emu->cur_thread == task->thread);
|
|
|
|
|
|
|
|
task->state = TASK_ST_DEAD;
|
|
|
|
task->thread = NULL;
|
|
|
|
emu->cur_thread->task = NULL;
|
|
|
|
|
|
|
|
emu->cur_task = task;
|
|
|
|
|
|
|
|
dbg("task id=%d ends\n", task->id);
|
|
|
|
}
|
|
|
|
|
2021-10-21 16:46:42 +02:00
|
|
|
static void
|
|
|
|
pre_task_running(struct ovni_emu *emu, struct nosv_task *task)
|
|
|
|
{
|
|
|
|
struct ovni_ethread *th;
|
|
|
|
struct ovni_eproc *proc;
|
|
|
|
|
|
|
|
th = emu->cur_thread;
|
|
|
|
proc = emu->cur_proc;
|
|
|
|
|
2021-10-29 17:48:04 +02:00
|
|
|
assert(task->id > 0);
|
|
|
|
assert(task->type_id > 0);
|
|
|
|
assert(proc->appid > 0);
|
|
|
|
|
|
|
|
chan_set(&th->chan[CHAN_NOSV_TASKID], task->id);
|
|
|
|
chan_set(&th->chan[CHAN_NOSV_TYPEID], task->type_id);
|
|
|
|
chan_set(&th->chan[CHAN_NOSV_APPID], proc->appid);
|
2021-10-11 11:12:26 +02:00
|
|
|
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_push(&th->chan[CHAN_NOSV_SUBSYSTEM], ST_NOSV_TASK_RUNNING);
|
2021-10-21 16:46:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2021-10-18 12:47:51 +02:00
|
|
|
pre_task_not_running(struct ovni_emu *emu)
|
2021-10-21 16:46:42 +02:00
|
|
|
{
|
|
|
|
struct ovni_ethread *th;
|
|
|
|
|
|
|
|
th = emu->cur_thread;
|
|
|
|
|
|
|
|
chan_set(&th->chan[CHAN_NOSV_TASKID], 0);
|
|
|
|
chan_set(&th->chan[CHAN_NOSV_TYPEID], 0);
|
|
|
|
chan_set(&th->chan[CHAN_NOSV_APPID], 0);
|
2021-10-11 11:12:26 +02:00
|
|
|
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_pop(&th->chan[CHAN_NOSV_SUBSYSTEM], ST_NOSV_TASK_RUNNING);
|
2021-10-21 16:46:42 +02:00
|
|
|
}
|
|
|
|
|
2021-07-29 17:46:25 +02:00
|
|
|
static void
|
|
|
|
pre_task(struct ovni_emu *emu)
|
|
|
|
{
|
2021-10-21 16:46:42 +02:00
|
|
|
struct nosv_task *task;
|
|
|
|
|
|
|
|
task = emu->cur_task;
|
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
switch(emu->cur_ev->header.value)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
|
|
|
case 'c': pre_task_create(emu); break;
|
|
|
|
case 'x': pre_task_execute(emu); break;
|
|
|
|
case 'e': pre_task_end(emu); break;
|
|
|
|
case 'p': pre_task_pause(emu); break;
|
|
|
|
case 'r': pre_task_resume(emu); break;
|
|
|
|
default:
|
2021-10-21 16:46:42 +02:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(emu->cur_ev->header.value)
|
|
|
|
{
|
|
|
|
case 'x':
|
|
|
|
case 'r':
|
|
|
|
pre_task_running(emu, task);
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
case 'e':
|
2021-10-18 12:47:51 +02:00
|
|
|
pre_task_not_running(emu);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case 'c':
|
|
|
|
default:
|
|
|
|
break;
|
2021-07-29 17:46:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-29 18:13:41 +02:00
|
|
|
static void
|
|
|
|
pre_type_create(struct ovni_emu *emu)
|
|
|
|
{
|
2021-07-30 21:37:25 +02:00
|
|
|
struct nosv_task_type *type;
|
2021-07-30 20:08:40 +02:00
|
|
|
uint8_t *data;
|
|
|
|
uint32_t *typeid;
|
|
|
|
const char *label;
|
2021-07-29 18:13:41 +02:00
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
if((emu->cur_ev->header.flags & OVNI_EV_JUMBO) == 0)
|
|
|
|
{
|
|
|
|
err("expecting a jumbo event\n");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
data = &emu->cur_ev->payload.jumbo.data[0];
|
|
|
|
typeid = (uint32_t *) data;
|
|
|
|
data += sizeof(*typeid);
|
|
|
|
label = (const char *) data;
|
2021-07-29 18:13:41 +02:00
|
|
|
|
|
|
|
/* Ensure the type id is new */
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_FIND_INT(emu->cur_proc->types, typeid, type);
|
2021-07-29 18:13:41 +02:00
|
|
|
|
|
|
|
if(type != NULL)
|
|
|
|
{
|
2021-07-30 20:08:40 +02:00
|
|
|
err("A task type with id %d already exists\n", *typeid);
|
2021-07-29 18:13:41 +02:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
|
|
|
type = calloc(1, sizeof(*type));
|
|
|
|
|
|
|
|
if(type == NULL)
|
|
|
|
{
|
|
|
|
perror("calloc");
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
type->id = *typeid;
|
|
|
|
type->label = label;
|
2021-07-29 18:13:41 +02:00
|
|
|
|
|
|
|
/* Add the new task type to the hash table */
|
2021-07-30 21:37:25 +02:00
|
|
|
HASH_ADD_INT(emu->cur_proc->types, id, type);
|
2021-07-29 18:13:41 +02:00
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
dbg("new task type created id=%d label=%s\n", type->id,
|
|
|
|
type->label);
|
2021-07-29 18:13:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
pre_type(struct ovni_emu *emu)
|
|
|
|
{
|
2021-07-30 20:08:40 +02:00
|
|
|
switch(emu->cur_ev->header.value)
|
2021-07-29 18:13:41 +02:00
|
|
|
{
|
|
|
|
case 'c': pre_type_create(emu); break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-21 16:46:42 +02:00
|
|
|
static void
|
|
|
|
pre_sched(struct ovni_emu *emu)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
2021-10-21 16:46:42 +02:00
|
|
|
struct ovni_ethread *th;
|
|
|
|
struct ovni_chan *chan_th;
|
|
|
|
|
|
|
|
th = emu->cur_thread;
|
|
|
|
chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM];
|
|
|
|
|
|
|
|
switch(emu->cur_ev->header.value)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
2021-10-21 16:46:42 +02:00
|
|
|
case 'h':
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_push(chan_th, ST_NOSV_SCHED_HUNGRY);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case 'f': /* Fill: no longer hungry */
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_pop(chan_th, ST_NOSV_SCHED_HUNGRY);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case '[': /* Server enter */
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_push(chan_th, ST_NOSV_SCHED_SERVING);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case ']': /* Server exit */
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_pop(chan_th, ST_NOSV_SCHED_SERVING);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case '@':
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_ev(chan_th, EV_NOSV_SCHED_SELF);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case 'r':
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_ev(chan_th, EV_NOSV_SCHED_RECV);
|
2021-10-21 16:46:42 +02:00
|
|
|
break;
|
|
|
|
case 's':
|
2021-10-14 07:30:27 +02:00
|
|
|
chan_ev(chan_th, EV_NOSV_SCHED_SEND);
|
2021-09-27 17:42:14 +02:00
|
|
|
break;
|
2021-07-29 17:46:25 +02:00
|
|
|
default:
|
2021-09-27 17:42:14 +02:00
|
|
|
break;
|
2021-07-29 17:46:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-15 11:31:23 +02:00
|
|
|
static void
|
|
|
|
pre_api(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct ovni_ethread *th;
|
|
|
|
struct ovni_chan *chan_th;
|
|
|
|
|
|
|
|
th = emu->cur_thread;
|
|
|
|
chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM];
|
|
|
|
|
|
|
|
switch(emu->cur_ev->header.value)
|
|
|
|
{
|
2021-10-19 10:21:10 +02:00
|
|
|
case 's': chan_push(chan_th, ST_NOSV_API_SUBMIT); break;
|
|
|
|
case 'S': chan_pop (chan_th, ST_NOSV_API_SUBMIT); break;
|
|
|
|
case 'p': chan_push(chan_th, ST_NOSV_API_PAUSE); break;
|
|
|
|
case 'P': chan_pop (chan_th, ST_NOSV_API_PAUSE); break;
|
|
|
|
case 'y': chan_push(chan_th, ST_NOSV_API_YIELD); break;
|
|
|
|
case 'Y': chan_pop (chan_th, ST_NOSV_API_YIELD); break;
|
|
|
|
case 'w': chan_push(chan_th, ST_NOSV_API_WAITFOR); break;
|
|
|
|
case 'W': chan_pop (chan_th, ST_NOSV_API_WAITFOR); break;
|
|
|
|
case 'c': chan_push(chan_th, ST_NOSV_API_SCHEDPOINT); break;
|
|
|
|
case 'C': chan_pop (chan_th, ST_NOSV_API_SCHEDPOINT); break;
|
|
|
|
default: break;
|
2021-10-15 11:31:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-25 12:35:05 +02:00
|
|
|
static void
|
|
|
|
pre_mem(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct ovni_ethread *th;
|
|
|
|
struct ovni_chan *chan_th;
|
|
|
|
|
|
|
|
th = emu->cur_thread;
|
|
|
|
chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM];
|
|
|
|
|
|
|
|
switch(emu->cur_ev->header.value)
|
|
|
|
{
|
|
|
|
case 'a': chan_push(chan_th, ST_NOSV_MEM_ALLOCATING); break;
|
|
|
|
case 'A': chan_pop (chan_th, ST_NOSV_MEM_ALLOCATING); break;
|
|
|
|
case 'f': chan_push(chan_th, ST_NOSV_MEM_FREEING); break;
|
|
|
|
case 'F': chan_pop (chan_th, ST_NOSV_MEM_FREEING); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-29 18:27:49 +02:00
|
|
|
static void
|
|
|
|
pre_thread_type(struct ovni_emu *emu)
|
|
|
|
{
|
|
|
|
struct ovni_ethread *th;
|
|
|
|
struct ovni_chan *chan_th;
|
|
|
|
|
|
|
|
th = emu->cur_thread;
|
|
|
|
chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM];
|
|
|
|
|
|
|
|
switch(emu->cur_ev->header.value)
|
|
|
|
{
|
|
|
|
case 'a': chan_push(chan_th, ST_NOSV_ATTACH); break;
|
|
|
|
case 'A': chan_pop (chan_th, ST_NOSV_ATTACH); break;
|
|
|
|
case 'w': chan_push(chan_th, ST_NOSV_WORKER); break;
|
|
|
|
case 'W': chan_pop (chan_th, ST_NOSV_WORKER); break;
|
|
|
|
case 'd': chan_push(chan_th, ST_NOSV_DELEGATE); break;
|
|
|
|
case 'D': chan_pop (chan_th, ST_NOSV_DELEGATE); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-13 14:44:20 +02:00
|
|
|
static void
|
2021-10-14 07:05:59 +02:00
|
|
|
pre_ss(struct ovni_emu *emu, int st)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
2021-10-21 16:46:42 +02:00
|
|
|
struct ovni_ethread *th;
|
|
|
|
struct ovni_chan *chan_th;
|
2021-07-29 17:46:25 +02:00
|
|
|
|
2021-10-21 16:46:42 +02:00
|
|
|
th = emu->cur_thread;
|
|
|
|
chan_th = &th->chan[CHAN_NOSV_SUBSYSTEM];
|
2021-07-29 17:46:25 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
assert(chan_th->id == CHAN_NOSV_SUBSYSTEM);
|
|
|
|
dbg("pre_ss chan id %d st=%d\n", chan_th->id, st);
|
|
|
|
|
2021-07-30 20:08:40 +02:00
|
|
|
switch(emu->cur_ev->header.value)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
2021-10-15 11:31:23 +02:00
|
|
|
case '[':
|
2021-10-14 07:05:59 +02:00
|
|
|
chan_push(chan_th, st);
|
2021-08-02 10:08:58 +02:00
|
|
|
break;
|
2021-10-21 16:46:42 +02:00
|
|
|
case ']':
|
2021-10-14 07:05:59 +02:00
|
|
|
chan_pop(chan_th, st);
|
2021-08-02 10:08:58 +02:00
|
|
|
break;
|
2021-07-29 17:46:25 +02:00
|
|
|
default:
|
2021-10-14 07:05:59 +02:00
|
|
|
err("unexpected value '%c' (expecting '[' or ']')\n",
|
|
|
|
emu->cur_ev->header.value);
|
|
|
|
abort();
|
2021-10-11 11:12:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-29 17:46:25 +02:00
|
|
|
void
|
2021-10-21 16:46:42 +02:00
|
|
|
hook_pre_nosv(struct ovni_emu *emu)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
2021-10-21 16:46:42 +02:00
|
|
|
assert(emu->cur_ev->header.model == 'V');
|
2021-10-21 16:15:29 +02:00
|
|
|
|
2021-10-18 12:47:51 +02:00
|
|
|
/* Ensure the thread is active */
|
|
|
|
assert(emu->cur_thread->is_active);
|
|
|
|
|
2021-10-11 15:46:49 +02:00
|
|
|
switch(emu->cur_ev->header.category)
|
2021-07-29 17:46:25 +02:00
|
|
|
{
|
2021-10-21 16:46:42 +02:00
|
|
|
case 'T': pre_task(emu); break;
|
|
|
|
case 'Y': pre_type(emu); break;
|
|
|
|
case 'S': pre_sched(emu); break;
|
2021-10-14 07:30:27 +02:00
|
|
|
case 'U': pre_ss(emu, ST_NOSV_SCHED_SUBMITTING); break;
|
2021-10-25 12:35:05 +02:00
|
|
|
case 'M': pre_mem(emu); break;
|
2021-10-29 18:27:49 +02:00
|
|
|
case 'H': pre_thread_type(emu); break;
|
2021-10-15 11:31:23 +02:00
|
|
|
case 'A': pre_api(emu); break;
|
2021-07-29 17:46:25 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-09-23 12:41:43 +02:00
|
|
|
}
|