int main(int argc, char *argv[]) { show_new_pagefault_count("Initial count", ">=0", ">=0"); configure_malloc_behavior(); show_new_pagefault_count("mlockall() generated", ">=0", ">=0"); reserve_process_memory(PRE_ALLOCATION_SIZE); show_new_pagefault_count("malloc() and touch generated", ">=0", ">=0"); /* Now allocate the memory for the 2nd time and prove the number of pagefaults are zero */ reserve_process_memory(PRE_ALLOCATION_SIZE); show_new_pagefault_count("2nd malloc() and use generated", "0", "0"); printf("\n\nLook at the output of ps -leyf, and see that the " \ "RSS is now about %d [MB]\n", PRE_ALLOCATION_SIZE / (1024 * 1024)); start_rt_thread(); //<do your RT-thing> printf("Press <ENTER> to exit\n"); getchar(); return 0; }
int main(int argc, char *argv[]) { int c; // l stands for message length opterr = 0; optind = 1; int argc_copy = argc; char *argv_copy[argc]; for (int i = 0; i < argc; ++i) { size_t len = strlen(argv[i]); argv_copy[i] = (char*) malloc(len); memcpy(argv_copy[i], argv[i], len); } while ((c = getopt(argc_copy, argv_copy, "l:")) != -1) { switch(c) { case 'l': message_length = std::stoul(std::string(optarg)); break; default: break; } } rttest_read_args(argc, argv); pub = new ExamplePublisher(); pub->message_size = message_length; pub->init(); sub = new ExampleSubscriber(); sub->init(); if (rttest_lock_memory() != 0) { perror("Failed to lock dynamic memory"); } rttest_prefault_stack(); start_rt_thread(&subscriber_thread); if (rttest_set_sched_priority(98, SCHED_RR) != 0) { perror("Failed to set scheduling priority and policy"); } publisher_thread(NULL); /* for (int i = 0; i < argc; ++i) { free(argv_copy[i]); } */ //delete sub; }