int main(int argc, char* argv[]){ int msg_id = shmget(MSG_NAME(0), 0, 0); volatile int* msg0 = shmat(msg_id, 0, 0); msg_id = shmget(MSG_NAME(1), 0, 0); volatile int* msg1 = shmat(msg_id, 0, 0); read_request(msg0, 6, 1); read_request(msg1, 3, 1); read_request(msg0, 8, 1); read_request(msg1, 9, 1); write_request(msg0, 1, 1, 1); write_request(msg0, 4, 3, 1); write_request(msg0, 2, 4, 1); write_request(msg1, 8, 3, 1); write_request(msg1, 7, 0, 1); int ans = read_request(msg0, 8, 1); printf("%d\n", ans); return 0; }
static enum { PROTO_TCP, PROTO_SCTP } dlm_protocol; static int kernel_monitor_fd = -1; static int control_fd = -1; static struct lockspace *lockspaces; static int joined_lockspaces; static struct node *nodes, *local_node; static node_mask_t all_nodes; static node_mask_t connected_nodes; static int shut_down; struct poll_callbacks cbs; static LIST_HEAD(aio_pending); LIST_HEAD(aio_completed); #define MSG_NAME(x) [MSG_ ## x] = #x static const char *msg_names[] = { MSG_NAME(CLOSE), MSG_NAME(STOP_LOCKSPACE), MSG_NAME(LOCKSPACE_STOPPED), MSG_NAME(JOIN_LOCKSPACE), MSG_NAME(LEAVE_LOCKSPACE), }; static const char *msg_name(enum msg_type type) { if (type >= ARRAY_SIZE(msg_names)) return NULL; return msg_names[type]; } static node_mask_t nodeid_mask(int nodeid)