X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=datarace.h;h=737a6d6e99a915a06d2f21d9f6a521a5ad126e03;hb=2d0d4ac38e05905a6633b3f2d5112ccadd45c27f;hp=e3cab5d6612aeb7f5770122ad27201a5245435f1;hpb=9b784333e1a62ed6d258e96502a5733041389c8f;p=model-checker.git diff --git a/datarace.h b/datarace.h index e3cab5d..737a6d6 100644 --- a/datarace.h +++ b/datarace.h @@ -1,7 +1,16 @@ -#ifndef DATARACE_H +/** @file datarace.h + * @brief Data race detection code. + */ + +#ifndef __DATARACE_H__ +#define __DATARACE_H__ + #include "config.h" #include -#include "clockvector.h" +#include "modeltypes.h" + +/* Forward declaration */ +class ModelAction; struct ShadowTable { void * array[65536]; @@ -11,30 +20,44 @@ struct ShadowBaseTable { uint64_t array[65536]; }; -#define MASK16BIT 0xffff +struct DataRace { + /* Clock and thread associated with first action. This won't change in + response to synchronization. */ -void initRaceDetector(); -void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock); -void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock); + thread_id_t oldthread; + modelclock_t oldclock; + /* Record whether this is a write, so we can tell the user. */ + bool isoldwrite; + /* Model action associated with second action. This could change as + a result of synchronization. */ + ModelAction *newaction; + /* Record whether this is a write, so we can tell the user. */ + bool isnewwrite; + /* Address of data race. */ + const void *address; +}; -/** Encoding idea: - * (void *) Either: - * (1) points to a full record or - * - * (2) encodes the information in a 64 bit word. Encoding is as - * follows: lowest bit set to 1, next 8 bits are read thread id, next - * 23 bits are read clock vector, next 8 bites are write thread id, - * next 23 bits are write clock vector. */ +#define MASK16BIT 0xffff +void initRaceDetector(); +void raceCheckWrite(thread_id_t thread, void *location); +void raceCheckRead(thread_id_t thread, const void *location); +bool checkDataRaces(); +void assert_race(struct DataRace *race); +bool haveUnrealizedRaces(); + +/** + * @brief A record of information for detecting data races + */ struct RaceRecord { - int *readClock; + modelclock_t *readClock; thread_id_t *thread; int capacity; int numReads; thread_id_t writeThread; - int writeClock; + modelclock_t writeClock; }; #define INITCAPACITY 4 @@ -51,9 +74,21 @@ struct RaceRecord { #define WRITEMASK READMASK #define WRITEVECTOR(x) (((x)>>40)&WRITEMASK) +/** + * The basic encoding idea is that (void *) either: + * -# points to a full record (RaceRecord) or + * -# encodes the information in a 64 bit word. Encoding is as + * follows: + * - lowest bit set to 1 + * - next 8 bits are read thread id + * - next 23 bits are read clock vector + * - next 8 bits are write thread id + * - next 23 bits are write clock vector + */ #define ENCODEOP(rdthread, rdtime, wrthread, wrtime) (0x1ULL | ((rdthread)<<1) | ((rdtime) << 9) | (((uint64_t)wrthread)<<32) | (((uint64_t)wrtime)<<40)) #define MAXTHREADID (THREADMASK-1) #define MAXREADVECTOR (READMASK-1) #define MAXWRITEVECTOR (WRITEMASK-1) -#endif + +#endif /* __DATARACE_H__ */