int main (int argc, char ** argv) { Int status = 0; UInt numLoops = NUM_LOOPS_DFLT; UInt16 procId = PROC_ID_DFLT; /* Parse Args: */ switch (argc) { case 1: /* use defaults */ break; case 2: numLoops = atoi(argv[1]); break; case 3: numLoops = atoi(argv[1]); procId = atoi(argv[2]); break; default: printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; ProcId: %d\n", NUM_LOOPS_DFLT, PROC_ID_DFLT); exit(0); } /* configure the transport factory */ Ipc_transportConfig(&TransportRpmsg_Factory); /* IPC initialization */ status = Ipc_start(); if (status < 0) { printf("Error: Ipc_start failed, error=%d\n", status); goto exit; } if ((procId == 0) || (procId >= MultiProc_getNumProcessors())) { printf("ProcId (%d) must be nonzero and less than %d\n", procId, MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; procId : %d\n", numLoops, procId); if (status >= 0) { MessageQApp_execute(numLoops, procId); Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); } exit: return (status); }
/* * ======== taskLoad ======== */ Void task(UArg arg1, UArg arg2) { UInt count = 1; Int status = Ipc_S_SUCCESS; UInt16 remoteProcId = MultiProc_getId("HOST"); do { status = Ipc_attach(remoteProcId); } while (status < 0); Notify_registerEvent(remoteProcId, 0, SHUTDOWN, (Notify_FnNotifyCbck)notifyCallbackFxn, 0); while (shutdownFlag == FALSE) { Semaphore_pend(sem, BIOS_WAIT_FOREVER); /* Benchmark how long it takes to flip all the bits */ Log_write1(UIABenchmark_start, (xdc_IArg)"Reverse"); reverseBits(buffer, sizeof(buffer)); Log_write1(UIABenchmark_stop, (xdc_IArg)"Reverse"); Log_print1(Diags_USER1, "count = %d", count++); } /* Start shutdown process */ Notify_unregisterEvent(remoteProcId, 0, SHUTDOWN, (Notify_FnNotifyCbck)notifyCallbackFxn, 0); do { status = Ipc_detach(remoteProcId); } while (status < 0); Ipc_stop(); }
int main (int argc, char * argv[]) { Int32 status = 0; UInt32 numLoops = NUM_LOOPS_DFLT; UInt32 payloadSize = MINPAYLOADSIZE; UInt16 procId = PROC_ID_DFLT; /* Parse args: */ if (argc > 1) { numLoops = strtoul(argv[1], NULL, 0); } if (argc > 2) { payloadSize = MAX(strtoul(argv[2], NULL, 0), MINPAYLOADSIZE); } if (argc > 3) { procId = atoi(argv[3]); } if (argc > 4) { printf("Usage: %s [<numLoops>] [<payloadSize>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; payloadSize: %d, ProcId: %d\n", NUM_LOOPS_DFLT, MINPAYLOADSIZE, PROC_ID_DFLT); exit(0); } status = Ipc_start(); if (procId >= MultiProc_getNumProcessors()) { printf("ProcId must be less than %d\n", MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; payloadSize: %d, procId : %d\n", numLoops, payloadSize, procId); if (status >= 0) { MessageQApp_execute(numLoops, payloadSize, procId); Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); } return (status); }
int main (int argc, char ** argv) { Int32 status = 0; UInt32 numLoops = NUM_LOOPS_DFLT; UInt16 procId = PROC_ID_DFLT; /* Parse Args: */ switch (argc) { case 1: /* use defaults */ break; case 2: numLoops = atoi(argv[1]); break; case 3: numLoops = atoi(argv[1]); procId = atoi(argv[2]); break; default: printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; ProcId: %d\n", NUM_LOOPS_DFLT, PROC_ID_DFLT); exit(0); } status = Ipc_start(); if (procId >= MultiProc_getNumProcessors()) { printf("ProcId must be less than %d\n", MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; procId : %d\n", numLoops, procId); if (status >= 0) { MessageQApp_execute(numLoops, procId); Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); } return(0); }
/* * ======== main ======== */ Int main(Int argc, Char* argv[]) { Int status; printf("--> main:\n"); /* parse command line */ status = Main_parseArgs(argc, argv); if (status < 0) { goto leave; } status = CMEM_init(); if (status < 0) { printf("CMEM_init failed\n"); goto leave; } else { printf("CMEM_init success\n"); } /* configure the transport factory */ Ipc_transportConfig(&TransportRpmsg_Factory); /* IPC initialization */ status = Ipc_start(); if (status >= 0) { /* application create, exec, delete */ status = Main_main(); /* Ipc finalization */ Ipc_stop(); } else { printf("Ipc_start failed: status = %d\n", status); goto leave; } leave: printf("<-- main:\n"); status = (status >= 0 ? 0 : status); return (status); }
/* * ======== IPC_threadGeneratedReset ======== */ Void IPC_threadGeneratedReset() { Int status; UInt16 masterId; masterId = MultiProc_getId("HOST"); do { status = Ipc_detach(masterId); } while (status < 0); do { status = Ipc_stop(); } while (status < 0); do { status = Ipc_start(); } while (status < 0); }
/* * ======== main ======== */ int main(int argc, char **argv) { int status; int32_t ret; UInt16 procId = PROC_ID_DFLT; printf("mmrpc_test: --> main\n"); /* Parse Args: */ switch (argc) { case 1: /* use defaults */ break; case 2: procId = atoi(argv[1]); break; default: printf("Usage: %s [<ProcId>]\n", argv[0]); printf("\tDefaults: ProcId: %d\n", PROC_ID_DFLT); exit(0); } #if defined(IPC_BUILDOS_QNX) /* Need to start IPC for MultiProc */ status = Ipc_start(); if (status < 0) { printf("Ipc_start failed: status = %d\n", status); return (0); } #endif /* initialize Mx module (setup rpc connection) */ status = Mx_initialize(procId); if (status < 0) { goto leave; } /* invoke Mx functions */ ret = Mx_triple(11); printf("mmrpc_test: Mx_triple(11), ret=%d\n", ret); if (ret < 0) { status = -1; goto leave; } ret = Mx_triple(111); printf("mmrpc_test: Mx_triple(111), ret=%d\n", ret); if (ret < 0) { status = -1; goto leave; } ret = Mx_add(44, 66); printf("mmrpc_test: Mx_add(44, 66), ret=%d\n", ret); if (ret < 0) { status = -1; goto leave; } #if defined(IPC_BUILDOS_QNX) ret = callCompute_QnX(); #else ret = callCompute_Linux(); #endif if (ret < 0) { status = -1; } leave: /* finalize Mx module (destroy rpc connection) */ Mx_finalize(); #if defined(IPC_BUILDOS_QNX) Ipc_stop(); #endif if (status < 0) { printf("mmrpc_test: FAILED\n"); } else { printf("mmrpc_test: PASSED\n"); } return(0); }
int main (int argc, char ** argv) { struct thread_info threads[MAX_NUM_THREADS]; int ret,i; Int32 status = 0; /* Parse Args: */ numLoops = NUM_LOOPS_DFLT; numThreads = NUM_THREADS_DFLT; procNum = ONE_PROCESS_ONLY; switch (argc) { case 1: /* use defaults */ break; case 2: numThreads = atoi(argv[1]); break; case 3: numThreads = atoi(argv[1]); numLoops = atoi(argv[2]); break; case 4: /* We force numThreads = 1 if doing a multiProcess test: */ numThreads = 1; numLoops = atoi(argv[2]); procNum = atoi(argv[3]); break; default: printf("Usage: %s [<numThreads>] [<numLoops>] [<Process #]>\n", argv[0]); printf("\tDefaults: numThreads: %d, numLoops: %d\n", NUM_THREADS_DFLT, NUM_LOOPS_DFLT); printf("\tMax Threads: %d\n", MAX_NUM_THREADS); exit(0); } if (numThreads > MAX_NUM_THREADS) { printf("Error: Maximum number of threads supported is %d\n", MAX_NUM_THREADS); exit(EXIT_FAILURE); } printf("Using numThreads: %d, numLoops: %d\n", numThreads, numLoops); if (procNum != ONE_PROCESS_ONLY) { printf("ProcNum: %d\n", procNum); } /* configure the transport factory */ Ipc_transportConfig(&TransportRpmsg_Factory); /* IPC initialization */ status = Ipc_start(); if (status < 0) { printf ("Ipc_start failed: status = 0x%x\n", status); goto exit; } /* Launch multiple threads: */ for (i = 0; i < numThreads; i++) { /* Create the test thread: */ printf ("creating pingThreadFxn: %d\n", i); threads[i].thread_num = (procNum == ONE_PROCESS_ONLY)? i: procNum; ret = pthread_create(&threads[i].thread_id, NULL, &pingThreadFxn, &(threads[i].thread_num)); if (ret) { printf("MessageQMulti: can't spawn thread: %d, %s\n", i, strerror(ret)); } } /* Join all threads: */ for (i = 0; i < numThreads; i++) { ret = pthread_join(threads[i].thread_id, NULL); if (ret != 0) { printf("MessageQMulti: failed to join thread: %d, %s\n", threads[i].thread_num, strerror(ret)); } printf("MessageQMulti: Joined with thread %d\n",threads[i].thread_num); } Ipc_stop(); exit: return (status); }
int main (int argc, char ** argv) { Int status = 0; int opt; UInt numLoops = NUM_LOOPS_DFLT; UInt16 procId = PROC_ID_DFLT; UInt32 faultId = 0; while ((opt = getopt(argc, argv, "f:")) != -1) { switch (opt) { case 'f': /* * Argument for -f corresponds to remote-side "fault" commands. * Negative commands cause remote fault before remote MessageQ_put. * Positive commands cause remote fault after remote MessageQ_put. */ faultId = atoi(optarg); printf("fault %d will be sent in 1st msg\n", faultId); break; default: fprintf(stderr, "Unknown arg '%s'\n", optarg); return 1; } } /* Parse Args: */ switch (argc - optind + 1) { case 1: /* use defaults */ break; case 2: numLoops = atoi(argv[optind]); break; case 3: numLoops = atoi(argv[optind]); procId = atoi(argv[optind + 1]); break; default: printf("Usage: %s [<numLoops>] [<ProcId>]\n", argv[0]); printf("\tDefaults: numLoops: %d; ProcId: %d\n", NUM_LOOPS_DFLT, PROC_ID_DFLT); exit(0); } /* configure the transport factory */ Ipc_transportConfig(&TransportRpmsg_Factory); /* IPC initialization */ status = Ipc_start(); if (status < 0) { printf("Error: Ipc_start failed, error=%d\n", status); goto exit; } if ((procId == 0) || (procId >= (MultiProc_getBaseIdOfCluster() + MultiProc_getNumProcessors()))) { printf("ProcId (%d) must be nonzero and less than %d\n", procId, MultiProc_getBaseIdOfCluster() + MultiProc_getNumProcessors()); Ipc_stop(); exit(0); } printf("Using numLoops: %d; procId : %d\n", numLoops, procId); if (MessageQApp_execute(numLoops, procId, faultId) < 0) { int nAttachAttempts = 1; printf("MessageQApp_execute failed, attempting detach/attach...\n"); Ipc_detach(procId); while (Ipc_attach(procId) != Ipc_S_SUCCESS) { nAttachAttempts++; if ((nAttachAttempts % 1000) == 0) { printf("Ipc_attach(%d) failed\n", procId); } } printf("Ipc_attach(%d) succeeded (after %d tries)\n", procId, nAttachAttempts); /* call without fault this time */ MessageQApp_execute(numLoops, procId, 0); } Ipc_stop(); exit: return (status); }