void init_mac_2threads() { // Start Sora HW if (params_rx->inType == TY_SORA) { RadioStart(*params_rx); InitSoraRx(*params_rx); } if (params_tx->outType == TY_SORA) { RadioStart(*params_tx); InitSoraTx(*params_tx); } // Start NDIS if (params_tx->inType == TY_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); assert(hResult == S_OK); Ndis_init(NULL); } if (params_rx->outType == TY_IP) { // To be implemented // HRESULT hResult = SoraUEnableGetRxPacket(); // assert(hResult == S_OK); } // Start measuring time initMeasurementInfo(&(params_tx->measurementInfo), params_tx->latencyCDFSize); // Init initBufCtxBlock(&buf_ctx_tx); initBufCtxBlock(&buf_ctx_rx); initHeapCtxBlock(&heap_ctx_tx); initHeapCtxBlock(&heap_ctx_rx); wpl_global_init_tx(params_tx->heapSize); wpl_global_init_rx(params_rx->heapSize); }
int __cdecl main(int argc, char **argv) { // Initialize the global parameters params = &Globals; try_parse_args(params, argc, argv); #ifdef SORA_PLATFORM // Start Sora HW if (Globals.inType == TY_SDR || Globals.outType == TY_SDR) { #ifdef BLADE_RF if (BladeRF_RadioStart(params) < 0) { exit(1); } #endif #ifdef SORA_RF // SORA RadioStart(&Globals); if (Globals.inType == TY_SDR) { InitSoraRx(params); } if (Globals.outType == TY_SDR) { InitSoraTx(params); } #endif } // Start NDIS if (Globals.inType == TY_IP || Globals.outType == TY_IP) { HRESULT hResult = SoraUEnableGetTxPacket(); assert(hResult == S_OK); Ndis_init(NULL); } // Start measuring time initMeasurementInfo(&(Globals.measurementInfo), Globals.latencyCDFSize); #endif // Init initBufCtxBlock(&buf_ctx); initHeapCtxBlock(&heap_ctx, Globals.heapSize); wpl_global_init(Globals.heapSize); wpl_input_initialize(); #ifdef SORA_PLATFORM ///////////////////////////////////////////////////////////////////////////// // DV: Pass the User_Routines here int no_threads = wpl_set_up_threads(User_Routines); printf("Setting up threads...\n"); ULONGLONG ttstart, ttend; printf("Starting %d threads...\n", no_threads); StartThreads(&ttstart, &ttend, &Globals.measurementInfo.tsinfo, no_threads, User_Routines); printf("Total input items (including EOF): %d (%d B), output items: %d (%d B)\n", buf_ctx.total_in, buf_ctx.total_in*buf_ctx.size_in, buf_ctx.total_out, buf_ctx.total_out*buf_ctx.size_out); printf("Time Elapsed: %ld us \n", SoraTimeElapsed((ttend / 1000 - ttstart / 1000), &Globals.measurementInfo.tsinfo)); if (Globals.latencySampling > 0) { printf("Min write latency: %ld, max write latency: %ld\n", (ulong)Globals.measurementInfo.minDiff, (ulong) Globals.measurementInfo.maxDiff); printf("CDF: \n "); unsigned int i = 0; while (i < Globals.measurementInfo.aDiffPtr) { printf("%ld ", Globals.measurementInfo.aDiff[i]); if (i % 10 == 9) { printf("\n "); } i++; } printf("\n"); } // Free thread separators // NB: these are typically allocated in blink_set_up_threads ts_free(); #else int usec; #ifdef __GNUC__ struct timespec start, end; clock_gettime(CLOCK_MONOTONIC, &start); wpl_go(); clock_gettime(CLOCK_MONOTONIC, &end); usec = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000; #else clock_t start = clock(), diff; wpl_go(); diff = clock() - start; usec = diff * 1000000 / CLOCKS_PER_SEC; #endif printf("Time Elapsed: %d\n", usec); #endif printf("Bytes copied: %ld\n", bytes_copied); wpl_output_finalize(); #ifdef SORA_PLATFORM // Stop Sora HW if (Globals.inType == TY_SDR || Globals.outType == TY_SDR) { #ifdef BLADE_RF BladeRF_RadioStop(params); #endif #ifdef SORA_RF RadioStop(&Globals); #endif } // Stop NDIS if (Globals.inType == TY_IP || Globals.outType == TY_IP) { if (hUplinkThread != NULL) { // Sora cleanup. SoraUThreadStop(hUplinkThread); SoraUThreadFree(hUplinkThread); } SoraUDisableGetTxPacket(); // Winsock cleanup. closesocket(ConnectSocket); WSACleanup(); } #endif return 0; }