MCPcopy Create free account
hub / github.com/axboe/liburing / main

Function main

examples/send-zerocopy.c:661–717  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

659}
660
661int main(int argc, char **argv)
662{
663 unsigned long long tsum = 0;
664 unsigned long long packets = 0, bytes = 0;
665 struct thread_data *td;
666 unsigned int i;
667 void *res;
668
669 page_size = sysconf(_SC_PAGESIZE);
670 if (page_size < 0) {
671 perror("sysconf(_SC_PAGESIZE)");
672 return 1;
673 }
674
675 parse_opts(argc, argv);
676 init_buffers();
677 set_cpu_affinity();
678
679 pthread_barrier_init(&barrier, NULL, cfg_nr_threads);
680 for (i = 0; i < cfg_nr_threads; i++) {
681 td = &threads[i];
682 td->idx = i;
683 }
684
685 if (cfg_rx)
686 do_setup_rx(cfg_family, cfg_type, 0);
687
688 if (!cfg_rx)
689 signal(SIGINT, sigint_handler);
690
691 for (i = 0; i < cfg_nr_threads; i++)
692 pthread_create(&threads[i].thread, NULL,
693 !cfg_rx ? do_test : do_rx, &threads[i]);
694
695 for (i = 0; i < cfg_nr_threads; i++) {
696 td = &threads[i];
697 pthread_join(td->thread, &res);
698 packets += td->packets;
699 bytes += td->bytes;
700 tsum += td->dt_ms;
701 }
702 tsum = tsum / cfg_nr_threads;
703
704 if (!tsum) {
705 printf("The run is too short, can't gather stats\n");
706 } else {
707 printf("packets=%llu (MB=%llu), rps=%llu (MB/s=%llu)\n",
708 packets, bytes >> 20,
709 packets * 1000 / tsum,
710 (bytes >> 20) * 1000 / tsum);
711 }
712
713 if (payload)
714 munmap(payload, alloc_size);
715 pthread_barrier_destroy(&barrier);
716 return 0;
717}

Callers

nothing calls this directly

Calls 4

set_cpu_affinityFunction · 0.85
do_setup_rxFunction · 0.85
parse_optsFunction · 0.70
init_buffersFunction · 0.70

Tested by

no test coverage detected