ovni/def.h

122 lines
2.1 KiB
C
Raw Normal View History

2021-07-19 15:11:41 +02:00
#ifndef OVNI_DEF_H
#define OVNI_DEF_H
#define MAX_CPU 256
#define MAX_PROC 32
2021-07-19 19:05:26 +02:00
#define MAX_THR 32
2021-07-19 15:11:41 +02:00
#define MAX_LOOM 4
#define TRACEDIR "ovni"
2021-07-22 12:35:02 +02:00
#define MAX_EV (16*1024) /* 16 kev per thread */
//#define MAX_EV (16) /* 16 ev per thread */
2021-07-19 19:05:26 +02:00
/* ----------------------- common ------------------------ */
enum thread_state {
ST_THREAD_UNINIT = 0,
ST_THREAD_INIT = 1
};
struct __attribute__((__packed__)) event {
uint64_t clock;
uint8_t fsm;
uint8_t event;
uint16_t a;
uint16_t b;
2021-07-19 19:05:26 +02:00
};
/* ----------------------- runtime ------------------------ */
/* State of each thread on runtime */
struct rthread {
/* Current cpu the thread is running on. Set to -1 if unbounded or
* unknown */
2021-07-19 15:11:41 +02:00
int cpu;
2021-07-19 19:05:26 +02:00
/* Current thread id */
pid_t tid;
/* Clock value of the events being emitted */
2021-07-19 15:11:41 +02:00
uint64_t clockvalue;
2021-07-19 19:05:26 +02:00
2021-07-22 12:35:02 +02:00
/* Stream trace file descriptor */
int streamfd;
2021-07-19 19:05:26 +02:00
int ready;
2021-07-22 12:35:02 +02:00
/* Buffer to write events */
int nevents;
struct event events[MAX_EV];
2021-07-19 15:11:41 +02:00
};
2021-07-19 19:05:26 +02:00
/* State of each process on runtime */
struct rproc {
/* Path of the process tracedir */
char dir[PATH_MAX];
2021-07-19 15:11:41 +02:00
int proc;
int loom;
int ncpus;
clockid_t clockid;
2021-07-19 19:05:26 +02:00
char procdir[PATH_MAX];
int ready;
2021-07-19 15:11:41 +02:00
};
2021-07-19 19:05:26 +02:00
/* ----------------------- emulated ------------------------ */
/* State of each thread on post-process */
struct ethread {
/* Emulated thread tid */
pid_t tid;
/* Stream file */
FILE *f;
/* Thread stream */
struct stream *stream;
2021-07-19 15:11:41 +02:00
};
2021-07-19 19:05:26 +02:00
/* State of each process on post-process */
struct eproc {
/* Monotonic counter for process index */
/* TODO: Use pid? */
int proc;
/* Path of the process tracedir */
char dir[PATH_MAX];
/* Threads */
size_t nthreads;
struct ethread thread[MAX_THR];
};
/* ----------------------- trace ------------------------ */
/* State of each loom on post-process */
struct loom {
size_t nprocs;
struct eproc proc[MAX_PROC];
2021-07-19 15:11:41 +02:00
};
2021-07-19 19:05:26 +02:00
struct stream {
2021-07-19 15:11:41 +02:00
FILE *f;
int tid;
int thread;
int proc;
int loom;
2021-07-19 15:11:41 +02:00
int loaded;
int active;
2021-07-19 19:05:26 +02:00
struct event last;
uint64_t lastclock;
2021-07-19 15:11:41 +02:00
};
2021-07-19 19:05:26 +02:00
struct trace {
2021-07-19 15:11:41 +02:00
int nlooms;
2021-07-19 19:05:26 +02:00
struct loom loom[MAX_LOOM];
2021-07-19 15:11:41 +02:00
int nstreams;
2021-07-19 19:05:26 +02:00
struct stream *stream;
2021-07-19 15:11:41 +02:00
};
#endif /* OVNI_DEF_H */