void main (int argc, char *argv[]) { mbox_t h_procs_mbox; // Semaphore to signal the original process that we're done mbox_t h_n2_mbox; // Convert the command-line strings into integers for use as handles h_procs_mbox = dstrtol(argv[1], NULL, 10); h_n2_mbox = dstrtol(argv[2], NULL, 10); if (mbox_open(h_n2_mbox) == MBOX_FAIL) { Printf("inject_n2 (%d): Could not open the mailbox!\n", getpid()); Exit(); } Printf("--PID %d: INJECT N2 molecule\n", getpid()); if (mbox_send(h_n2_mbox, 0, NULL) == MBOX_FAIL) { Printf("inject_n2 (%d): Could not map the virtual address to the memory!\n", getpid()); Exit(); } // Signal the mbox to tell the original process that we're done if (mbox_open(h_procs_mbox) == MBOX_FAIL) { Printf("inject_n2 (%d): Could not open the mailbox!\n", getpid()); Exit(); } if (mbox_send(h_procs_mbox, 0, NULL) == MBOX_FAIL) { Printf("inject_n2 (%d): Could not map the virtual address to the memory!\n", getpid()); Exit(); } // Printf("*****%s ended\n", argv[0]); }
void mbox_test(void) { int mbox_id = mbox_init(1); assert(mbox_id >= 0); struct mboxbuf __buf, *buf = &__buf; buf->size = 4096; buf->len = buf->size; buf->data = (void *)0xF0000000; assert(mbox_send(mbox_id, buf) < 0); buf->data = malloc(sizeof(char) * buf->size); assert(buf->data != NULL); char *data = (char *)(buf->data); int i; for (i = 0; i < buf->size; i++) { data[i] = (char)i; } buf->len = buf->size; unsigned int timeout = 100, saved_msec = gettime_msec(); assert(mbox_send(mbox_id, buf) == 0); assert(mbox_send_timeout(mbox_id, buf, timeout) == -E_TIMEOUT); assert((unsigned int)(gettime_msec() - saved_msec) >= timeout); size_t saved_size = buf->size; buf->size = 100; assert(mbox_recv(mbox_id, buf) != 0); buf->size = saved_size - 1; assert(mbox_recv(mbox_id, buf) != 0); buf->size = saved_size; memset(buf->data, 0, sizeof(char) * buf->size); assert(mbox_recv(mbox_id, buf) == 0); assert(buf->size == saved_size && buf->len == saved_size); data = (char *)(buf->data); for (i = 0; i < buf->size; i++) { assert(data[i] == (char)i); } saved_msec = gettime_msec(); assert(mbox_recv_timeout(mbox_id, buf, timeout) == -E_TIMEOUT); assert((unsigned int)(gettime_msec() - saved_msec) >= timeout); assert(mbox_free(mbox_id) == 0); assert(mbox_send(mbox_id, buf) != 0); exit(0); }
void main (int argc, char *argv[]) { missile_code mc; // Used to access missile codes from mailbox mbox_t mbox_N2; // Handle to the mbox_N2 mbox_t mbox_N; //Handle to mbox_N sem_t s_procs_completed; // Semaphore to signal the original process that we're done if (argc != 4) { Printf("Usage: %s <handle_to_mailbox> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles mbox_N2 = dstrtol(argv[1], NULL, 10); // The "10" means base 10 mbox_N = dstrtol(argv[2], NULL ,10); s_procs_completed = dstrtol(argv[3], NULL, 10); // Open the mailbox if (mbox_open(mbox_N2) == MBOX_FAIL) { Printf("spawn_me (%d): Could not open the mailbox_N2!\n", getpid()); Exit(); } if (mbox_open(mbox_N) == MBOX_FAIL) { Printf("spawn_me (%d): Could not open the mailbox_N!\n", getpid()); Exit(); } // Wait for a message from the mailbox if (mbox_recv(mbox_N2, sizeof(mc), (void *)&mc) == MBOX_FAIL) { Printf("Could not receive message from mbox_N2!\n"); Exit(); } if (mbox_send(mbox_N, sizeof(missile_code),(void *)&mc) == MBOX_FAIL){ Printf("Could not send message to mbox_N!\n"); Exit(); } if (mbox_send(mbox_N, sizeof(missile_code),(void *)&mc) == MBOX_FAIL){ Printf("Could not send message to mbox_N!\n"); Exit(); } // Now print a message to show that everything worked // Printf("spawn_me (%d): Received missile code: %c\n", getpid(), mc.really_important_char); // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("spawn_me (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } // Printf("spawn_me (%d): Done!\n", getpid()); }
static void tegra186_bpmp_ivc_notify(struct tegra_ivc *ivc) { struct tegra186_bpmp *priv = container_of(ivc, struct tegra186_bpmp, ivc); int ret; ret = mbox_send(&priv->mbox, NULL); if (ret) error("mbox_send() failed: %d\n", ret); }
/* Instructs the controller handler to send a message to the controller(s). * Can be called from any thread; will send an async message to the connection thread. */ void ctrl_send_msg(struct ctrl *ctrl, size_t conn_id, of_xid_t xid, struct ofl_msg_header *msg) { struct ctrl_msg *message = malloc(sizeof(struct ctrl_msg)); message->conn_id = conn_id; message->xid = xid; message->msg = msg; logger_log(ctrl->logger, LOG_DEBUG, "Sending request for message."); mbox_send(ctrl->msg_mbox, (struct list_node *)message); }
int octeontx_mbox_send(struct octeontx_mbox_hdr *hdr, void *txdata, uint16_t txlen, void *rxdata, uint16_t rxlen) { struct mbox *m = &octeontx_mbox; RTE_BUILD_BUG_ON(sizeof(struct mbox_ram_hdr) != 8); if (rte_eal_process_type() != RTE_PROC_PRIMARY) return -EINVAL; return mbox_send(m, hdr, txdata, txlen, rxdata, rxlen); }
/* Sends a packet on the driver's given port. * Can be used by other threads. */ bool pcap_drv_send_pkt(struct pcap_drv *drv, size_t drv_port_no, struct pkt_buf *pkt_buf) { pthread_rwlock_rdlock(drv->ports_rwlock); struct pcap_port *port = drv->ports[drv_port_no]; pthread_rwlock_unlock(drv->ports_rwlock); if (port != NULL) { mbox_send(port->pkt_mbox, (struct list_node *)pkt_buf); //TODO limit? return true; } else { return false; } }
/* Instructs the controller handler to add a new connection. * Can be called from any thread; will send an async message to the connection thread. */ void ctrl_add_conn(struct ctrl *ctrl, const char *trans, const char *host, const char *port) { assert(host != NULL); struct ctrl_cmd *cmd = malloc(sizeof(struct ctrl_cmd)); cmd->type = CMD_ADD_CONN; cmd->add_conn.trans = (trans == NULL) ? NULL : strdup(trans); cmd->add_conn.host = strdup(host); cmd->add_conn.port = (port == NULL) ? NULL : strdup(port); logger_log(ctrl->logger, LOG_DEBUG, "Sending request for connection: %s:%s:%s.", STR_DEF(trans, "DEF"), host, STR_DEF(port, "DEF")); mbox_send(ctrl->cmd_mbox, (struct list_node *)cmd); }
void main (int argc, char *argv[]) { char so4[SO4_SIZE] = {'S', 'O', '4'}; mbox_t h_mbox; // Handle to the mailbox sem_t s_procs_completed; // Semaphore to signal the original process that we're done if (argc != 3) { Printf("Usage: %s <handle_to_mailbox> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles h_mbox = dstrtol(argv[1], NULL, 10); // The "10" means base 10 s_procs_completed = dstrtol(argv[2], NULL, 10); // Open the mailbox if (mbox_open(h_mbox) == MBOX_FAIL) { Printf("Generator SO4 (%d): Could not open the mailbox!\n", getpid()); Exit(); } // Send a message to the mailbox if (mbox_send(h_mbox, SO4_SIZE, (void *) so4) == MBOX_FAIL) { Printf("Generator SO4 (%d): Could not send message to the mailbox %d!\n", getpid(), h_mbox); Exit(); } // Now print a message to show that everything worked Printf("Generate SO4 Molecule\n"); // Close the mbox if (mbox_close(h_mbox) == MBOX_FAIL) { Printf("Generator SO4 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("Generator SO4 (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } Printf("Generator SO4 (%d): Done!\n", getpid()); }
void pp_send_msg(struct packetproc *packetproc, struct pl_pkt *pl_pkt, uint32_t process_id, uint32_t input_id) { struct pp *pp; pthread_mutex_lock(packetproc->mutex); HASH_FIND(hh, packetproc->pp_map, &process_id, sizeof(size_t), pp); if(pp == NULL) { logger_log(packetproc->logger, LOG_ERR, "There is no pp whit proc_id %d", process_id); pthread_mutex_unlock(packetproc->mutex); return; } pthread_mutex_unlock(packetproc->mutex); struct pp_msg *pp_msg = malloc(sizeof(struct pp_msg)); pp_msg->pl_pkt = pl_pkt_clone(pl_pkt); pp_msg->process_id = process_id; pp_msg->input_id = input_id; mbox_send(pp->msg_mbox,(struct list_node *)pp_msg); }
/** * k3_sysctrler_load() - Loadup the K3 remote processor * @dev: corresponding K3 remote processor device * @addr: Address in memory where image binary is stored * @size: Size in bytes of the image binary * * Return: 0 if all goes good, else appropriate error message. */ static int k3_sysctrler_load(struct udevice *dev, ulong addr, ulong size) { struct k3_sysctrler_privdata *priv = dev_get_priv(dev); struct k3_sysctrler_load_msg firmware; struct k3_sec_proxy_msg msg; int ret; debug("%s: Loading binary from 0x%08lX, size 0x%08lX\n", __func__, addr, size); memset(&firmware, 0, sizeof(firmware)); memset(&msg, 0, sizeof(msg)); /* Setup the message */ k3_sysctrler_load_msg_setup(&firmware, priv, addr, size); msg.len = sizeof(firmware); msg.buf = (u32 *)&firmware; /* Send the message */ ret = mbox_send(&priv->chan_tx, &msg); if (ret) { dev_err(dev, "%s: Firmware Loading failed. ret = %d\n", __func__, ret); return ret; } /* Receive the response */ ret = mbox_recv(&priv->chan_rx, &msg, priv->desc->max_rx_timeout_us); if (ret) { dev_err(dev, "%s: Firmware Load response failed. ret = %d\n", __func__, ret); return ret; } /* Process the response */ ret = k3_sysctrler_load_response(msg.buf); if (ret) return ret; debug("%s: Firmware Loaded successfully on dev %s\n", __func__, dev->name); return 0; }
void main (int argc, char *argv[]) { sem_t s_procs_completed; // Semaphore to signal the original process that we're done mbox_t mb_n2; // mailbox for H2O atom Printf("Starting N2 Injection - PID %d \n", getpid()); if (argc > 4 ) { Printf("Usage: "); Printf(argv[0]); Printf(" <handle_to_proc_semaphore> <handle_to_N2_mailbox>\n"); Exit(); } // Convert the command-line strings into integers for use as handles s_procs_completed = dstrtol(argv[1], NULL, 10); mb_n2 = dstrtol(argv[2], NULL, 10); if(!mbox_open(mb_n2)){ Printf("Bad mailbox open mb_n2\n"); Exit(); } Printf("opened n2 mailbox\n"); if(mbox_send(mb_n2, 2, (void *) "N2") != MBOX_SUCCESS){ Printf("N2 send error\n"); } Printf("Sent N2 to mb_n2\n"); if(!mbox_close(mb_n2)){ Printf("Bad mailbox open mb_n2\n"); Exit(); } // Signal the semaphore to tell the original process that we're done Printf("Inject N2: PID %d is complete.\n", getpid()); if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("Bad semaphore s_procs_completed (%d) in ", s_procs_completed); Printf(argv[0]); Printf(", exiting...\n"); Exit(); } }
void main (int argc, char *argv[]) { message m; // Used to access missile codes from mailbox //mbox_t h_mbox; // Handle to the mailbox sem_t s_procs_completed; // Semaphore to signal the original process that we're done int h2o_mbox; if (argc != 3) { Printf("\tUsage: %s <handle_to_h2o_mailbox> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles h2o_mbox = dstrtol(argv[1], NULL, 10); // The "10" means base 10 s_procs_completed = dstrtol(argv[2], NULL, 10); // Open the mailbox if (mbox_open(h2o_mbox) == MBOX_FAIL) { Printf("\tspawn_water (%d): Could not open h2o the mailbox!\n", getpid()); Exit(); } if (mbox_send(h2o_mbox, sizeof(m), (void *)&m) == MBOX_FAIL) { Printf("\tspawn_water (%d): Could not map the virtual address to the memory!\n", getpid()); Exit(); } // Now print a message to show that everything worked Printf("\tspawn_water (%d): H2O molcule created. Injecting it into atmosphere. %d\n", getpid()); Printf("\tspawn_water (%d): Done!\n\n", getpid()); // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("\tspawn_water (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } }
void main (int argc, char *argv[]) { int ct; char h2o_buffer_1[H2O_SIZE]; char h2o_buffer_2[H2O_SIZE]; char h2_molecule[H2_SIZE] = {'H', '2'}; char o2_molecule[O2_SIZE] = {'O', '2'}; mbox_t h_mbox_h2o; // Handle to the mailbox for h2o mbox_t h_mbox_h2; mbox_t h_mbox_o2; sem_t s_procs_completed; // Semaphore to signal the original process that we're done if (argc != 5) { Printf("Usage: %s <mailbox h2o> <mailbox h2> <mailbox o2> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles h_mbox_h2o = dstrtol(argv[1], NULL, 10); // The "10" means base 10 h_mbox_h2 = dstrtol(argv[2], NULL, 10); // The "10" means base 10 h_mbox_o2 = dstrtol(argv[3], NULL, 10); // The "10" means base 10 s_procs_completed = dstrtol(argv[4], NULL, 10); // Open the h2o mailbox if (mbox_open(h_mbox_h2o) == MBOX_FAIL) { Printf("Reaction 1 (%d): Could not open the h2o mailbox!\n", getpid()); Exit(); } // Wait for the first h2o molecule from the mailbox if (mbox_recv(h_mbox_h2o, H2O_SIZE, (void *) h2o_buffer_1) == MBOX_FAIL) { Printf("Reaction 1 (%d): Could not receive message from the mbox %d!\n", getpid(), h_mbox_h2o); Exit(); } // Wait for the second h2o molecule from the mailbox if (mbox_recv(h_mbox_h2o, H2O_SIZE, (void *) h2o_buffer_2) == MBOX_FAIL) { Printf("Reaction 1 (%d): Could not receive message from the mbox %d!\n", getpid(), h_mbox_h2o); Exit(); } // Close the h2o mailbox if (mbox_close(h_mbox_h2o) == MBOX_FAIL) { Printf("Reaction 1 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the h2 mailbox if (mbox_open(h_mbox_h2) == MBOX_FAIL) { Printf("Reaction 1 (%d): Could not open the h2 mailbox!\n", getpid()); Exit(); } // Send the first h2 to the h2 mailbox if (mbox_send(h_mbox_h2, H2_SIZE, (void *) h2_molecule) == MBOX_FAIL) { Printf("Generator h2 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_h2); Exit(); } // Send the second h2 to the h2 mailbox if (mbox_send(h_mbox_h2, H2_SIZE, (void *) h2_molecule) == MBOX_FAIL) { Printf("Generator h2 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_h2); Exit(); } // Close the h2 mailbox if (mbox_close(h_mbox_h2) == MBOX_FAIL) { Printf("Generator h2 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the o2 mailbox if (mbox_open(h_mbox_o2) == MBOX_FAIL) { Printf("Reaction 1 (%d): Could not open the o2 mailbox!\n", getpid()); Exit(); } // Send the o2 to the o2 mailbox if (mbox_send(h_mbox_o2, O2_SIZE, (void *) o2_molecule) == MBOX_FAIL) { Printf("Reaction o2 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_o2); Exit(); } // Close the o2 mailbox if (mbox_close(h_mbox_o2) == MBOX_FAIL) { Printf("Reaction o2 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Now print a message to show that everything worked Printf("Two molecules H2 has been generated\n"); Printf("A molecule O2 has been generated\n"); // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("Reaction 1 (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } Printf("Reaction 1 (%d): Done!\n", getpid()); }
void main (int argc, char *argv[]) { message m; // Used to access missile codes from mailbox mbox_t h_mbox; // Handle to the mailbox sem_t s_procs_completed; // Semaphore to signal the original process that we're done int so4_mbox,so2_mbox,o2_mbox; if (argc != 5) { Printf("\tUsage: %s <handle_to_so4_mailbox> <handle_to_so2_mailbox> <handle_to_o2_mailbox> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles so4_mbox = dstrtol(argv[1], NULL, 10); // The "10" means base 10 so2_mbox = dstrtol(argv[2], NULL, 10); o2_mbox = dstrtol(argv[3], NULL, 10); s_procs_completed = dstrtol(argv[4], NULL, 10); // Open the mailbox if (mbox_open(so4_mbox) == MBOX_FAIL) { Printf("\tspawn_rx2 (%d): Could not open the so4 mailbox!\n", getpid()); Exit(); } if (mbox_open(so2_mbox) == MBOX_FAIL) { Printf("\tspawn_rx2 (%d): Could not open the so2 mailbox!\n", getpid()); Exit(); } if (mbox_open(o2_mbox) == MBOX_FAIL) { Printf("\tspawn_rx2 (%d): Could not open the o2 mailbox!\n", getpid()); Exit(); } // Wait for a message from the mailbox if (mbox_recv(so4_mbox, sizeof(m), (void *)&m) == MBOX_FAIL) { Printf("\tspawn_rx2 (%d): Could not map the virtual address to the memory!\n", getpid()); Exit(); } Printf("\tspawn_rx2 (%d): One SO4 molecule present. Begin reaction...\n", getpid()); // sleep(1); if (mbox_send(so2_mbox, sizeof(m), (void *)&m) == MBOX_FAIL) { Printf("\tspawn_rx2 (%d): Could not map the virtual address to the memory!\n", getpid()); Exit(); } Printf("\tspawn_rx2 (%d):Created an SO2 molecule... continue\n", getpid()); // sleep(1); if (mbox_send(o2_mbox, sizeof(m), (void *)&m) == MBOX_FAIL) { Printf("\tspawn_rx2 (%d): Could not map the virtual address to the memory!\n", getpid()); Exit(); } Printf("\tspawn_rx2 (%d):Created an O2 molecule\n", getpid()); // Now print a message to show that everything worked //Printf("\tspawn_rx2 (%d): Reaction is process, will take %d seconds\n", getpid(),10); //sleep(10); Printf("\tspawn_rx2 (%d): Done!\n\n", getpid()); // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("\tspawn_rx2 (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } }
void main (int argc, char *argv[]) { char h2_buffer[H2_SIZE]; char o2_buffer[O2_SIZE]; char so2_buffer[SO2_SIZE]; char h2so4_molecule[H2SO4_SIZE] = {'H', '2', 'S', 'O', '4'}; mbox_t h_mbox_h2; mbox_t h_mbox_o2; mbox_t h_mbox_so2; mbox_t h_mbox_h2so4; sem_t s_procs_completed; // Semaphore to signal the original process that we're done /* int ct; */ /* Printf("argc = %d\n", argc); */ /* for(ct = 0 ; ct < argc; ct++){ */ /* Printf("argv[%d] = %s\n", ct, argv[ct]); */ /* } */ if (argc != 6) { Printf("Usage: %s <mailbox h2> <mailbox o2> <mailbox so2> <mailbox h2so4> <handle_to_page_mapped_semaphore>\n"); Exit(); } // Convert the command-line strings into integers for use as handles h_mbox_h2 = dstrtol(argv[1], NULL, 10); // The "10" means base 10 h_mbox_o2 = dstrtol(argv[2], NULL, 10); // The "10" means base 10 h_mbox_so2 = dstrtol(argv[3], NULL, 10); // The "10" means base 10 h_mbox_h2so4 = dstrtol(argv[4], NULL, 10); // The "10" means base 10 s_procs_completed = dstrtol(argv[5], NULL, 10); // Open the h2 mailbox if (mbox_open(h_mbox_h2) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not open the so4 mailbox!\n", getpid()); Exit(); } // Wait for the h2 molecule from the mailbox if (mbox_recv(h_mbox_h2, H2_SIZE, (void *) h2_buffer) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not receive message from the mbox %d!\n", getpid(), h_mbox_h2); Exit(); } // Close the h2 mailbox if (mbox_close(h_mbox_h2) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the o2 mailbox if (mbox_open(h_mbox_o2) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not open the o2 mailbox!\n", getpid()); Exit(); } // Send the o2 to the o2 mailbox if (mbox_recv(h_mbox_o2, O2_SIZE, (void *) o2_buffer) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_o2); Exit(); } // Close the o2 mailbox if (mbox_close(h_mbox_o2) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the SO2 mailbox if (mbox_open(h_mbox_so2) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not open the so2 mailbox!\n", getpid()); Exit(); } // Send the SO2 to the SO2 mailbox if (mbox_recv(h_mbox_so2, SO2_SIZE, (void *) so2_buffer) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_so2); Exit(); } // Close the SO2 mailbox if (mbox_close(h_mbox_so2) == MBOX_FAIL) { Printf("Reaction 2 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Open the h2so4 mailbox if (mbox_open(h_mbox_h2so4) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not open the h2so4 mailbox!\n", getpid()); Exit(); } // Send the h2so4 to the o2 mailbox if (mbox_send(h_mbox_h2so4, H2SO4_SIZE, (void *) h2so4_molecule) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not send message to the mbox %d!\n", getpid(), h_mbox_h2so4); Exit(); } // Close the h2so4 mailbox if (mbox_close(h_mbox_h2so4) == MBOX_FAIL) { Printf("Reaction 3 (%d): Could not close the mailbox!\n", getpid()); Exit(); } // Now print a message to show that everything worked Printf("A molecule H2SO4 has been generated\n"); // Signal the semaphore to tell the original process that we're done if(sem_signal(s_procs_completed) != SYNC_SUCCESS) { Printf("Reaction 3 (%d): Bad semaphore s_procs_completed (%d)!\n", getpid(), s_procs_completed); Exit(); } Printf("Reaction 3 (%d): Done!\n", getpid()); }