examples: add eal cleanup to examples
[dpdk.git] / examples / service_cores / main.c
index 2cd5729..2b57a52 100644 (file)
@@ -118,6 +118,12 @@ apply_profile(int profile_id)
        struct profile *p = &profiles[profile_id];
        const uint8_t core_off = 1;
 
+       if (p->num_cores > rte_lcore_count() + 1) {
+               printf("insufficent cores to run (%s)",
+                       p->name);
+               return;
+       }
+
        for (i = 0; i < p->num_cores; i++) {
                uint32_t core = i + core_off;
                ret = rte_service_lcore_add(core);
@@ -203,10 +209,10 @@ main(int argc, char **argv)
                apply_profile(i);
                printf("\n==> Profile: %s\n\n", profiles[i].name);
 
-               sleep(1);
+               rte_delay_us_sleep(1 * US_PER_S);
                rte_service_dump(stdout, UINT32_MAX);
 
-               sleep(5);
+               rte_delay_us_sleep(5 * US_PER_S);
                rte_service_dump(stdout, UINT32_MAX);
 
                i++;
@@ -214,5 +220,8 @@ main(int argc, char **argv)
                        i = 0;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }