My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
baremetal_msu.c
Go to the documentation of this file.
3 #include "local_msu.h"
4 #include "rt_stats.h"
5 #include "msu_type.h"
6 #include "msu_message.h"
7 #include "logging.h"
8 #include "msu_calls.h"
9 #include "profiler.h"
10 #include "routing_strategies.h"
11 #include <stdlib.h>
12 
13 static int receive(struct local_msu *self, struct msu_msg *msu_msg) {
14  struct baremetal_msg *msg = msu_msg->data;
15  msg->n_hops--;
16 
17  if (msg->n_hops == 0) {
19  int rtn = close(msg->fd);
20  if (rtn < 0) {
21  log_error("Error closing file descriptor %d", msg->fd);
22  }
23  free(msg);
24  return 0;
25  }
26 
27  return call_msu_type(self, self->type, &msu_msg->hdr, sizeof(*msg), msg);
28 }
29 
30 static int route(struct msu_type *type, struct local_msu *sender,
31  struct msu_msg *msg, struct msu_endpoint *output) {
32  struct baremetal_msg *bm_msg = msg->data;
33  if (bm_msg->n_hops <= 1) {
34  return route_to_origin_runtime(type, sender, msg, output);
35  }
36  return default_routing(type, sender, msg, output);
37 }
38 
40  .name = "Baremetal_Msu",
42  .receive = receive,
43  .route = route
44 };
45 
Collecting statistics within the runtime.
Defines a type of MSU, including callback and accessor functions.
int default_routing(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
The defualt routing strategy, using the key of the MSU message to route to a pre-defined endpoint...
struct msu_type BAREMETAL_MSU_TYPE
Definition: baremetal_msu.c:39
static int route(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
Definition: baremetal_msu.c:30
void * data
Payload.
Definition: msu_message.h:104
Logging of status messages to the terminal.
For profiling the path of MSU messages through DeDOS.
Declares the methods available for calling an MSU from another MSU.
#define log_error(fmt,...)
Definition: logging.h:101
Declares the structures and functions applicable to MSUs on the local machine.
#define PROFILE_EVENT(hdr, stat_id)
If the header is marked for profiling, profiles the given event.
Definition: profiler.h:77
Profiling.
Definition: stat_ids.h:68
The structure that represents an MSU located on the local machine.
Definition: local_msu.h:38
#define BAREMETAL_MSU_TYPE_ID
Definition: baremetal_msu.h:4
int call_msu_type(struct local_msu *sender, struct msu_type *dst_type, struct msu_msg_hdr *hdr, size_t data_size, void *data)
Sends an MSU message to a destination of the given type, utilizing the sending MSU's routing function...
Definition: msu_calls.c:146
Defines a type of MSU.
Definition: msu_type.h:46
struct msu_msg_hdr hdr
Definition: msu_message.h:102
A message that is to be delivered to an instance of an MSU.
Definition: msu_message.h:101
Messages passed to MSUs.
char * name
Name for the msu type.
Definition: msu_type.h:48
An endpoint to which an msu_msg can be delivered.
Definition: routing.h:32
int route_to_origin_runtime(struct msu_type *type, struct local_msu *sender, struct msu_msg *msg, struct msu_endpoint *output)
Routes an MSU message to the runtime on which the message originated.
static int receive(struct local_msu *self, struct msu_msg *msu_msg)
Definition: baremetal_msu.c:13
Declares strategies that MSUs can use for routing to endpoints.