blob: db63b48f1d4dda1800d51249d187cffadb1a1811 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
* pm_be_polluter.c
*
* Best Effort Cache Polluter Task
*/
#include "pm_common.h"
#include "pm_arch.h"
#include "asm.h"
int mem_block[NUMWS][INTS_PER_WSS] __attribute__ ((aligned(CACHEALIGNMENT)));
int main(int argc, char **argv)
{
int read, *loc_ptr;
memset(&mem_block, 0, sizeof(int) * NUMWS * INTS_PER_WSS);
/* Initialize random library for read/write ratio enforcement. */
srandom(SEEDVAL);
while(1) {
read = (random() % 100) < READRATIO;
loc_ptr = &mem_block[random() % NUMWS][0];
loc_ptr += (random() % INTS_PER_WSS);
barrier();
if (read)
read_mem(loc_ptr);
else
write_mem(loc_ptr);
/* FIXME is really needed? */
usleep(40);
}
/* never reached */
return 0;
}
|