diff options
| author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-04-12 23:20:49 -0400 |
|---|---|---|
| committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-04-12 23:20:49 -0400 |
| commit | a225a4cf05861dc602816c296ac2a84d0b8bc7a4 (patch) | |
| tree | 095e0595bb886b85cf372d2bfcbe919b5d70d009 | |
| parent | dfacda3b8b51e9d0207ddcf6f4c8f9e2f231d4f7 (diff) | |
Add best-effort cache polluter
| -rw-r--r-- | SConstruct | 2 | ||||
| -rw-r--r-- | bin/pm_polluter.c | 40 |
2 files changed, 41 insertions, 1 deletions
| @@ -191,7 +191,7 @@ pmpy.Replace(LINKFLAGS = '') | |||
| 191 | # Preemption and migration overhead analysis | 191 | # Preemption and migration overhead analysis |
| 192 | 192 | ||
| 193 | pmrt.Program('pm_task', ['bin/pm_task.c', 'bin/pm_common.c']) | 193 | pmrt.Program('pm_task', ['bin/pm_task.c', 'bin/pm_common.c']) |
| 194 | 194 | pmrt.Program('pm_polluter', ['bin/pm_polluter.c', 'bin/pm_common.c']) | |
| 195 | # ##################################################################### | 195 | # ##################################################################### |
| 196 | # Additional Help | 196 | # Additional Help |
| 197 | 197 | ||
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 | |||
| 10 | int mem_block[NUMWS][INTS_PER_WSS] __attribute__ ((aligned(CACHEALIGNMENT))); | ||
| 11 | |||
| 12 | int 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 | |||
