@@ -29,7 +29,9 @@ auto MiriGenmcShim::handle_mutex_lock(ThreadId thread_id, uint64_t address, uint
29
29
)
30
30
));
31
31
32
- // Mutex starts out unlocked, so we always say the previous value is "unlocked".
32
+ // As usual, we need to tell GenMC which value was stored at this location before this atomic
33
+ // access, if there previously was a non-atomic initializing access. We set the initial state of
34
+ // a mutex to be "unlocked".
33
35
const auto old_val = MUTEX_UNLOCKED;
34
36
const auto load_ret = handle_load_reset_if_none<EventLabel::EventLabelKind::LockCasRead>(
35
37
thread_id,
@@ -84,7 +86,9 @@ auto MiriGenmcShim::handle_mutex_lock(ThreadId thread_id, uint64_t address, uint
84
86
auto MiriGenmcShim::handle_mutex_try_lock (ThreadId thread_id, uint64_t address, uint64_t size)
85
87
-> MutexLockResult {
86
88
auto & currPos = threads_action_[thread_id].event ;
87
- // Mutex starts out unlocked, so we always say the previous value is "unlocked".
89
+ // As usual, we need to tell GenMC which value was stored at this location before this atomic
90
+ // access, if there previously was a non-atomic initializing access. We set the initial state of
91
+ // a mutex to be "unlocked".
88
92
const auto old_val = MUTEX_UNLOCKED;
89
93
const auto load_ret = GenMCDriver::handleLoad<EventLabel::EventLabelKind::TrylockCasRead>(
90
94
++currPos,
@@ -131,7 +135,9 @@ auto MiriGenmcShim::handle_mutex_unlock(ThreadId thread_id, uint64_t address, ui
131
135
const auto pos = inc_pos (thread_id);
132
136
const auto ret = GenMCDriver::handleStore<EventLabel::EventLabelKind::UnlockWrite>(
133
137
pos,
134
- // Mutex starts out unlocked, so we always say the previous value is "unlocked".
138
+ // As usual, we need to tell GenMC which value was stored at this location before this
139
+ // atomic access, if there previously was a non-atomic initializing access. We set the
140
+ // initial state of a mutex to be "unlocked".
135
141
/* old_val */ MUTEX_UNLOCKED,
136
142
MemOrdering::Release,
137
143
SAddr (address),
0 commit comments