My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
local_msu.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 */
25 #ifndef LOCAL_MSU_H_
26 #define LOCAL_MSU_H_
27 #include "msu_type.h"
28 #include "message_queue.h"
29 #include "worker_thread.h"
30 
31 // Forward declaration due to circular dependency
32 struct msu_msg_hdr;
33 struct msu_msg_key;
34 
38 struct local_msu {
39 
45  struct msu_type *type;
46 
51  struct route_set routes;
52 
54  unsigned int id;
55 
57  unsigned int scheduling_weight;
58 
60  struct msg_queue queue;
61 
64 
66  void *msu_state;
67 
70 };
71 
80 struct local_msu *init_msu(unsigned int id, struct msu_type *type,
81  struct worker_thread *thread, struct msu_init_data *data);
82 
87 int try_destroy_msu(struct local_msu *msu);
88 
90 void destroy_msu(struct local_msu *msu);
91 
97 int msu_dequeue(struct local_msu *msu);
98 
104 struct local_msu *get_local_msu(unsigned int id);
105 
106 int msu_error(struct local_msu *msu, struct msu_msg_hdr *hdr, int broadcast);
107 #endif
The publicly accessible copy of the routing table.
Definition: routing.h:55
struct local_msu * get_local_msu(unsigned int id)
Gets the local MSU with the given ID, or NULL if N/A.
Definition: local_msu.c:134
Header for messages passed to MSUs.
Definition: msu_message.h:85
Defines a type of MSU, including callback and accessor functions.
Representation of a thread that holds MSUs, messages, and waits on a semaphore.
Definition: worker_thread.h:40
unsigned int scheduling_weight
The number of items that should be dequeued on this MSU each tick.
Definition: local_msu.h:57
void * msu_state
State related to the entire instance of the MSU, not just individual items.
Definition: local_msu.h:66
Container for linked list message queue.
Definition: message_queue.h:56
int msu_error(struct local_msu *msu, struct msu_msg_hdr *hdr, int broadcast)
Definition: local_msu.c:353
unsigned int id
Unique ID for a local MSU.
Definition: local_msu.h:54
Threads that hold MSUs.
int try_destroy_msu(struct local_msu *msu)
Destroys the MSU, but only if it has no states currently saved.
Definition: local_msu.c:249
struct msu_state * item_state
Keyed state structure, accessible through queue item IDs.
Definition: local_msu.h:63
struct route_set routes
Routing table set, containing all destination MSUs (see routing.h for details)
Definition: local_msu.h:51
The structure that represents an MSU located on the local machine.
Definition: local_msu.h:38
Data with which an MSU is initialized, and the payload for messages of type CTRL_CREATE_MSU.
Definition: dfg.h:66
Structures and functions for enqueueing and dequeuing general-purpose messages from a queue...
struct local_msu * init_msu(unsigned int id, struct msu_type *type, struct worker_thread *thread, struct msu_init_data *data)
Allocates and creates a new MSU of the specified type and ID on the given thread. ...
Definition: local_msu.c:198
struct msg_queue queue
Input queue to MSU.
Definition: local_msu.h:60
void destroy_msu(struct local_msu *msu)
Calls type-specific destroy function and frees associated memory.
Definition: local_msu.c:257
struct worker_thread * thread
The worker thread on which this MSU is placed.
Definition: local_msu.h:69
The structure contining msu state.
Definition: msu_state.c:35
Defines a type of MSU.
Definition: msu_type.h:46
Used to uniquely identify the source of a message, used in state storage as well as routing...
Definition: msu_message.h:46
int msu_dequeue(struct local_msu *msu)
Dequeus a message from a local MSU and calls its receive function.
Definition: local_msu.c:323
struct msu_type * type
Pointer to struct containing information shared across all instances of this type of MSU...
Definition: local_msu.h:45