My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
thread_message.h
Go to the documentation of this file.
1 /*
2 START OF LICENSE STUB
3  DeDOS: Declarative Dispersion-Oriented Software
4  Copyright (C) 2017 University of Pennsylvania, Georgetown University
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 END OF LICENSE STUB
19 */
26 #ifndef THREAD_MESSAGE_H_
27 #define THREAD_MESSAGE_H_
28 #include "runtime_communication.h"
29 #include "inter_runtime_messages.h"
30 #include "rt_controller_messages.h"
31 
38 
39  // For the output monitor thread
41  SEND_TO_PEER = 1000,
42  SEND_TO_CTRL = 1001,
44  // For worker threads
45  CREATE_MSU = 2001,
46  DELETE_MSU = 2002,
47  MSU_ROUTE = 3001,
48 };
49 
51 struct thread_msg {
53  int ack_id;
54  ssize_t data_size;
55  void *data;
56 };
57 
60  unsigned int runtime_id;
62  void *data;
63 };
64 
68  void *data;
69 };
70 
79 struct thread_msg *init_send_thread_msg(unsigned int runtime_id,
80  unsigned int target_id,
81  size_t data_len,
82  void *data);
83 
85 void destroy_thread_msg(struct thread_msg *msg);
86 
89  ssize_t data_size, void *data);
90 
92 int enqueue_thread_msg(struct thread_msg *msg, struct msg_queue *queue);
93 
98 struct thread_msg *dequeue_thread_msg(struct msg_queue *queue);
99 
100 #endif
struct thread_msg * init_send_thread_msg(unsigned int runtime_id, unsigned int target_id, size_t data_len, void *data)
Initializes a send_to_peer message (SEND_TO_PEER)
struct rt_controller_msg_hdr hdr
Kept unknown at 0 to catch mis-labeled messages.
ctrl_delete_msu_msg (ctrl_runtime_messages.h)
void destroy_thread_msg(struct thread_msg *msg)
Frees a thread message.
Socket-handling between runtimes.
thread_msg_type
All messages that can be received by output thread or workers.
For delivery to the output monitor thread, a message to be sent to a peer runtime.
Header for messages to runtime from another runtime.
int enqueue_thread_msg(struct thread_msg *msg, struct msg_queue *queue)
Enqueues a dedos_msg with a thread_msg as the payload to the appropriate queue.
Container for linked list message queue.
Definition: message_queue.h:56
enum thread_msg_type type
Header for all messages from controller to runtime.
payload: send_to_ctrl_msg (below)
For delivery to output monitor thread, a message to be sent to the controller.
A message to be delivered to a dedos_thread.
struct inter_runtime_msg_hdr hdr
Definitions of the message types that can be passed between runtimes.
struct thread_msg * construct_thread_msg(enum thread_msg_type type, ssize_t data_size, void *data)
Allocates and initializes a thread message with the provided options.
ctrl_create_msu_msg (ctrl_runtime_messages.h)
ssize_t data_size
Definitiions of structures for sending messages from runtimes to controller.
struct thread_msg * dequeue_thread_msg(struct msg_queue *queue)
Dequeues a thread_msg from the message queue.
ctrl_msu_route_msg (ctrl_runtime_messages.h)
int ack_id
for sending acknowledgements to controller.
static int runtime_id(int runtime_fd)
payload: send_to_runtime_msg (below)
payload: ctrl_add_runtime_msg (ctrl_runtime_messages.h)
unsigned int runtime_id
The runtime ID to which the message is delivered.