summaryrefslogtreecommitdiffstats
path: root/bin/pm_polluter.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pm_polluter.c')
-rw-r--r--bin/pm_polluter.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/bin/pm_polluter.c b/bin/pm_polluter.c
new file mode 100644
index 0000000..db63b48
--- /dev/null
+++ b/bin/pm_polluter.c
@@ -0,0 +1,40 @@
1/*
2 * pm_be_polluter.c
3 *
4 * Best Effort Cache Polluter Task
5 */
6#include "pm_common.h"
7#include "pm_arch.h"
8#include "asm.h"
9
10int mem_block[NUMWS][INTS_PER_WSS] __attribute__ ((aligned(CACHEALIGNMENT)));
11
12int main(int argc, char **argv)
13{
14 int read, *loc_ptr;
15
16 memset(&mem_block, 0, sizeof(int) * NUMWS * INTS_PER_WSS);
17
18 /* Initialize random library for read/write ratio enforcement. */
19 srandom(SEEDVAL);
20
21 while(1) {
22 read = (random() % 100) < READRATIO;
23 loc_ptr = &mem_block[random() % NUMWS][0];
24 loc_ptr += (random() % INTS_PER_WSS);
25
26 barrier();
27
28 if (read)
29 read_mem(loc_ptr);
30 else
31 write_mem(loc_ptr);
32
33 /* FIXME is really needed? */
34 usleep(40);
35 }
36
37 /* never reached */
38 return 0;
39}
40