static int shared_mem_test(char *message, int len) { rd_t memrd = open_shared_mem(); if (memrd < 0) { strncpy(message, "Unable to open shared mem.", len); return FAILED; } swrite(memrd, IPC_MESSAGE); new_task(&memreader, 1, 0); int count = 100000; while (!passed && (count-- > 0)); if (passed == 1) { return PASSED; } else if (passed == -1) { strncpy(message, "Message mismatch", len); } else { strncpy(message, "Timed out", len); } return FAILED; }
void ipctest(int argc, char **argv) { if (argc != 1) { printf("Usage: %s\n", argv[0]); return; } rd_t memrd = open_shared_mem(); if (memrd < 0) { printf("Error: unable to open shared mem.\r\n"); } printf("WRITING MEM.\r\n"); swrite(memrd, "THIS IS A TEST OF SHARED MEMORY REGIONS N STUFF."); printf("READING MEM.\r\n"); new_task(&memreader, 5, 0); }