2009-10-13 01:50:35 +00:00
|
|
|
/*
|
|
|
|
* dirtyPage.c
|
|
|
|
*
|
|
|
|
* Created on: Oct 12, 2009
|
|
|
|
* Author: sears
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stasis/transactional.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
char * usage = "%s numthreads numops\n";
|
|
|
|
|
|
|
|
stasis_dirty_page_table_t * dpt;
|
|
|
|
|
|
|
|
unsigned long numops;
|
|
|
|
unsigned long numthreads;
|
|
|
|
Page ** p;
|
|
|
|
|
|
|
|
static void* worker(void* arg) {
|
|
|
|
Page * p = arg;
|
|
|
|
for(unsigned long i = 0; i < numops; i++) {
|
2009-10-15 02:33:08 +00:00
|
|
|
writelock(p->rwlatch,0);
|
2009-10-13 01:50:35 +00:00
|
|
|
stasis_dirty_page_table_set_dirty(dpt, p);
|
2009-10-15 02:33:08 +00:00
|
|
|
unlock(p->rwlatch);
|
2009-10-13 01:50:35 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
if(argc != 3) { printf(usage, argv[0]); abort(); }
|
|
|
|
char * endptr;
|
|
|
|
numthreads = strtoul(argv[1], &endptr, 10);
|
|
|
|
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
|
|
|
|
numops= strtoul(argv[2], &endptr, 10) / numthreads;
|
|
|
|
if(*endptr != 0) { printf(usage, argv[0]); abort(); }
|
|
|
|
|
|
|
|
pthread_t workers[numthreads];
|
|
|
|
|
|
|
|
Page * p;
|
|
|
|
Tinit();
|
|
|
|
|
|
|
|
dpt = stasis_runtime_dirty_page_table();
|
|
|
|
|
|
|
|
p = loadPage(-1,0);
|
|
|
|
|
|
|
|
for(int i = 0; i < numthreads; i++) {
|
|
|
|
pthread_create(&workers[i], 0, worker, p);
|
|
|
|
}
|
|
|
|
for(int i = 0; i < numthreads; i++) {
|
|
|
|
pthread_join(workers[i], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
releasePage(p);
|
|
|
|
|
|
|
|
Tdeinit();
|
|
|
|
}
|