ovni/emu_nosv_ss.c

119 lines
2.4 KiB
C
Raw Normal View History

2021-09-23 10:41:53 +02:00
#include <assert.h>
#include "uthash.h"
#include "ovni.h"
#include "ovni_trace.h"
#include "emu.h"
#include "prv.h"
2021-10-21 16:15:29 +02:00
#include "chan.h"
2021-09-23 10:41:53 +02:00
/* This module manages the nos-v subsystem (ss) events, to track which
* actions are being performed by each thread at a given time. A stack
* of states is stored in each thread, so we remember the path of
* execution. Events such as task received by a thread are emitted as
* fake events with very short period. */
/* --------------------------- pre ------------------------------- */
static void
pre_sched(struct ovni_emu *emu)
{
struct ovni_ethread *th;
2021-10-21 16:15:29 +02:00
struct ovni_chan *chan;
2021-09-23 10:41:53 +02:00
th = emu->cur_thread;
2021-10-21 16:15:29 +02:00
chan = &th->chan[CHAN_NOSV_SS];
2021-09-23 10:41:53 +02:00
switch(emu->cur_ev->header.value)
{
case 'h':
2021-10-21 16:15:29 +02:00
chan_push(chan, ST_SCHED_HUNGRY);
2021-09-23 10:41:53 +02:00
break;
case 'f': /* Fill: no longer hungry */
2021-10-21 16:15:29 +02:00
chan_pop(chan, ST_SCHED_HUNGRY);
2021-09-23 10:41:53 +02:00
break;
case '[': /* Server enter */
2021-10-21 16:15:29 +02:00
chan_push(chan, ST_SCHED_SERVING);
2021-09-23 10:41:53 +02:00
break;
case ']': /* Server exit */
2021-10-21 16:15:29 +02:00
chan_pop(chan, ST_SCHED_SERVING);
2021-09-23 10:41:53 +02:00
break;
2021-10-21 16:15:29 +02:00
case '@': chan_ev(chan, EV_SCHED_SELF); break;
case 'r': chan_ev(chan, EV_SCHED_RECV); break;
case 's': chan_ev(chan, EV_SCHED_SEND); break;
2021-09-23 10:41:53 +02:00
default:
break;
}
}
static void
pre_submit(struct ovni_emu *emu)
{
struct ovni_ethread *th;
2021-10-21 16:15:29 +02:00
struct ovni_chan *chan;
2021-09-23 10:41:53 +02:00
th = emu->cur_thread;
2021-10-21 16:15:29 +02:00
chan = &th->chan[CHAN_NOSV_SS];
2021-09-23 10:41:53 +02:00
2021-09-23 15:12:55 +02:00
switch(emu->cur_ev->header.value)
{
2021-10-21 16:15:29 +02:00
case '[': chan_push(chan, ST_SCHED_SUBMITTING); break;
case ']': chan_pop(chan, ST_SCHED_SUBMITTING); break;
2021-09-23 15:12:55 +02:00
default:
break;
}
}
static void
2021-10-21 16:15:29 +02:00
pre_memory(struct ovni_emu *emu)
{
struct ovni_ethread *th;
2021-10-21 16:15:29 +02:00
struct ovni_chan *chan;
th = emu->cur_thread;
2021-10-21 16:15:29 +02:00
chan = &th->chan[CHAN_NOSV_SS];
switch(emu->cur_ev->header.value)
{
2021-10-21 16:15:29 +02:00
case '[': chan_push(chan, ST_MEM_ALLOCATING); break;
case ']': chan_pop(chan, ST_MEM_ALLOCATING); break;
default:
2021-10-21 16:15:29 +02:00
break;
}
}
2021-09-23 10:41:53 +02:00
void
hook_pre_nosv_ss(struct ovni_emu *emu)
{
2021-10-21 16:15:29 +02:00
assert(emu->cur_ev->header.model == 'V');
switch(emu->cur_ev->header.class)
2021-09-23 10:41:53 +02:00
{
2021-10-21 16:15:29 +02:00
case 'S': pre_sched(emu); break;
case 'U': pre_submit(emu); break;
case 'M': pre_memory(emu); break;
2021-09-23 10:41:53 +02:00
default:
2021-09-27 17:42:14 +02:00
break;
2021-09-23 10:41:53 +02:00
}
}
/* --------------------------- emit ------------------------------- */
void
hook_emit_nosv_ss(struct ovni_emu *emu)
{
struct ovni_ethread *th;
2021-10-21 16:15:29 +02:00
struct ovni_chan *chan;
2021-09-23 10:41:53 +02:00
th = emu->cur_thread;
2021-10-21 16:15:29 +02:00
chan_emit(&th->chan[CHAN_NOSV_SS]);
2021-09-23 10:41:53 +02:00
}
/* --------------------------- post ------------------------------- */
void
hook_post_nosv_ss(struct ovni_emu *emu)
{
}