X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/eea4e2cc87b80c35b33f46377187181e57692440..3c5b31c9766da42c82473b8c9dbf5910b74f3cb0:/src/mc/mc_server.h diff --git a/src/mc/mc_server.h b/src/mc/mc_server.h new file mode 100644 index 0000000000..559d0850b7 --- /dev/null +++ b/src/mc/mc_server.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2015. The SimGrid Team. + * All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#ifndef MC_SERVER_H +#define MC_SERVER_H + +#include + +SG_BEGIN_DECL() + +#define MC_SERVER_ERROR 127 + +typedef struct s_mc_server s_mc_server_t, *mc_server_t; + +extern mc_server_t mc_server; + +/** Initialise MC server + * + * @param PID of the model-checked process + * @param socket file descriptor for communication with the model-checked process + * @return 0 on success + */ +int MC_server_init(pid_t pid, int socket); + +/** Execute the MC server + * + * @return Status code (can be used with `exit()`) + */ +void MC_server_run(void); + +SG_END_DECL() + +#ifdef __cplusplus + +struct s_mc_server { +private: + pid_t pid; + int socket; + struct pollfd fds[2]; +public: + s_mc_server(pid_t pid, int socket); + void start(); + void shutdown(); + void exit(); + void resume(mc_process_t process); + void loop(); + void handle_events(); +protected: + void handle_signals(); + void handle_waitpid(); + void on_signal(const struct signalfd_siginfo* info); +}; + +#endif + +#endif