API breakage:
worker_sync takes an extra parameter (worker_t) to perform a wait-on-event instead of a busy waiting, reducing consummer ressources. worker_init takes an int instead of an unsigned int for the number of workers. It allows additional extra value -1 to initialize the number of workers to twice the number of CPU, allowing to overload the CPU with loads and keep them fully working in some scenario.
This commit is contained in:
1 parent
b684a62f8b
commit
3f5406f1d4
2 files changed
+27
-10
No files matched your search
@@ -52,7 +52,7 @@ static int fib(int n)
|
||||
f.n = n - 2;
|
||||
worker_spawn (w_g, b, subfunc_1, &f);
|
||||
int y = fib (n-1);
|
||||
worker_sync(b);
|
||||
worker_sync(w_g, b);
|
||||
return f.x + y;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ static int fib2(int n)
|
||||
worker_start(b);
|
||||
WORKER_SPAWN(w_g, b, (n), { y2 = fib2(n-2); }, (y2));
|
||||
y1 = fib (n-1);
|
||||
worker_sync(b);
|
||||
worker_sync(w_g, b);
|
||||
return y1 + y2;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user