Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
b6677d98da7bf5f127db1885df69d7701587fd66
[simgrid.git] / src / mc / mc_server.h
1 /* Copyright (c) 2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef MC_SERVER_H
8 #define MC_SERVER_H
9
10 #include <stdint.h>
11 #include <stdbool.h>
12
13 #include <sys/signalfd.h>
14 #include <sys/types.h>
15
16 #include <xbt/misc.h>
17  
18 #include "mc_process.h"
19
20 SG_BEGIN_DECL()
21
22 #define MC_SERVER_ERROR 127
23
24 typedef struct s_mc_server s_mc_server_t, *mc_server_t;
25
26 extern mc_server_t mc_server;
27
28 void MC_server_wait_client(mc_process_t process);
29 void MC_server_simcall_handle(mc_process_t process, unsigned long pid, int value);
30
31 SG_END_DECL()
32
33 #ifdef __cplusplus
34
35 struct s_mc_server {
36 private:
37   pid_t pid;
38   int socket;
39   struct pollfd fds[2];
40 public:
41   s_mc_server(pid_t pid, int socket);
42   void start();
43   void shutdown();
44   void exit();
45   void resume(mc_process_t process);
46   void loop();
47   bool handle_events();
48 protected:
49   void handle_signals();
50   void handle_waitpid();
51   void on_signal(const struct signalfd_siginfo* info);
52 };
53
54 #endif
55
56 #endif