//
// Written by Mike Feeley, University of BC, 2010
// Do not redistribute or otherwise make available any portion of this code to anyone without written permission of the author.
//
#include
#include
#include
#include “spinlock.h”
#include “uthread.h”
#ifndef NUM_ITERATIONS
#define NUM_ITERATIONS 100
#endif
#ifndef NUM_READERS
#define NUM_READERS 16
#endif
#ifndef NUM_WRITERS
#define NUM_WRITERS 4
#endif
#ifndef NUM_PROCESSORS
#define NUM_PROCESSORS 2
#endif
#ifndef MONITOR_HOLD_WAIT
#define MONITOR_HOLD_WAIT 100000
#endif
struct control_t {
spinlock_t lock;
int reader_count;
int writer_count;
int reader_histogram[NUM_READERS+NUM_WRITERS];
} control;
uthread_monitor_t* monitor;
void init () {
int i;
control.reader_count = 0;
control.writer_count = 0;
for (i=0; i