ovni/def.h

108 lines
1.8 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-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;
int32_t data;
};
/* ----------------------- 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
/* Stream trace file */
FILE *stream;
enum thread_state state;
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];
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 cpu;
int loaded;
int active;
2021-07-19 19:05:26 +02:00
struct event last;
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 */