X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=datarace.h;h=a83116bb311d21fe5b0bc738baf9ebc21b318664;hb=0bcdc6472ef63a9bd55a8e7bde3d103708e48078;hp=5bfcb8ad48cc98d007612805c2cc48567dedf984;hpb=c5b57f3d98d1d14b4546995a0882753cf71a1c4b;p=c11tester.git diff --git a/datarace.h b/datarace.h index 5bfcb8ad..a83116bb 100644 --- a/datarace.h +++ b/datarace.h @@ -2,11 +2,13 @@ * @brief Data race detection code. */ -#ifndef DATARACE_H +#ifndef __DATARACE_H__ +#define __DATARACE_H__ + #include "config.h" #include -#include "clockvector.h" -#include +#include "modeltypes.h" +#include "classlist.h" struct ShadowTable { void * array[65536]; @@ -18,7 +20,7 @@ struct ShadowBaseTable { struct DataRace { /* Clock and thread associated with first action. This won't change in - response to synchronization. */ + response to synchronization. */ thread_id_t oldthread; modelclock_t oldclock; @@ -26,34 +28,27 @@ struct DataRace { bool isoldwrite; /* Model action associated with second action. This could change as - a result of synchronization. */ + a result of synchronization. */ ModelAction *newaction; /* Record whether this is a write, so we can tell the user. */ bool isnewwrite; /* Address of data race. */ - void *address; + const void *address; }; #define MASK16BIT 0xffff void initRaceDetector(); -void raceCheckWrite(thread_id_t thread, void *location, ClockVector *currClock); -void raceCheckRead(thread_id_t thread, void *location, ClockVector *currClock); +void raceCheckWrite(thread_id_t thread, void *location); +void raceCheckRead(thread_id_t thread, const void *location); bool checkDataRaces(); -void printRace(struct DataRace *race); - -extern std::vector unrealizedraces; - -/** Basic 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. */ +void assert_race(struct DataRace *race); +bool haveUnrealizedRaces(); +/** + * @brief A record of information for detecting data races + */ struct RaceRecord { modelclock_t *readClock; thread_id_t *thread; @@ -77,9 +72,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__ */