source:
src/tests/preempt_longrun/processor.c
@
beefc34c
Last change on this file since beefc34c was 85b1deb, checked in by , 6 years ago | |
---|---|
|
|
File size: 748 bytes |
Rev | Line | |
---|---|---|
[cc3e4d0] | 1 | #include <kernel> |
2 | #include <thread> | |
[b9da9585] | 3 | #include <time> |
[cd99ef1] | 4 | |
[ea8b2f7] | 5 | #include <unistd.h> |
6 | ||
[cc3e4d0] | 7 | #ifndef PREEMPTION_RATE |
[b9da9585] | 8 | #error PREEMPTION_RATE not defined in makefile |
[cc3e4d0] | 9 | #endif |
10 | ||
[8ad6533] | 11 | Duration default_preemption() { |
[cc3e4d0] | 12 | return PREEMPTION_RATE; |
13 | } | |
14 | ||
[85b1deb] | 15 | static const unsigned long N = 50_000ul; |
[b9da9585] | 16 | |
[cc3e4d0] | 17 | int main(int argc, char* argv[]) { |
[e5d4e5c] | 18 | processor * p[15]; |
[85b1deb] | 19 | write(STDOUT_FILENO, "Preparing\n", sizeof("Preparing\n")); |
[e5d4e5c] | 20 | for ( int pi = 0; pi < 15; pi++ ) { |
21 | p[pi] = new(); | |
22 | } | |
[85b1deb] | 23 | write(STDOUT_FILENO, "Starting\n", sizeof("Starting\n")); |
[e5d4e5c] | 24 | for ( int i = 0; i < N; i++) { |
25 | int pi = i % 15; | |
26 | delete( p[pi] ); | |
27 | p[pi] = new(); | |
[cc3e4d0] | 28 | } |
[85b1deb] | 29 | write(STDOUT_FILENO, "Stopping\n", sizeof("Stopping\n")); |
[863c413] | 30 | for ( int pi = 0; pi < 15; pi++ ) { |
31 | delete( p[pi] ); | |
32 | } | |
[85b1deb] | 33 | write(STDOUT_FILENO, "Done\n", sizeof("Done\n")); |
[1449d83] | 34 | } |
Note: See TracBrowser
for help on using the repository browser.