Skip to content

Instantly share code, notes, and snippets.

@tuanpmt
Created May 2, 2022 11:33
Show Gist options
  • Save tuanpmt/4356641e6804db6093e288d644df87d7 to your computer and use it in GitHub Desktop.
Save tuanpmt/4356641e6804db6093e288d644df87d7 to your computer and use it in GitHub Desktop.
fib_task
void core1_task(void *ptr)
{
int i = ((thread_args *) ptr)->input;
((thread_args *) ptr)->output = fib(i);
xSemaphoreGive(xSemaphore);
vTaskDelete(NULL);
}
int test_dual_core(int num)
{
thread_args args;
int start, end, f;
start = xTaskGetTickCount();
args.input = num - 1;
xTaskCreatePinnedToCore(core1_task, "core1", 10*1024, &args, 10, NULL, 1);
f = fib(num - 2);
xSemaphoreTake(xSemaphore, portMAX_DELAY);
f += args.output;
end = xTaskGetTickCount();
return end - start;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment