Clocks should be unsigned and documented as their own 'modelclock_t' type.
#include "threads.h"
#include "libatomic.h"
#include "mymemory.h"
+#include "clockvector.h"
+
#define VALUE_NONE -1
typedef enum action_type {
action_type get_type() const { return type; }
memory_order get_mo() const { return order; }
void * get_location() const { return location; }
- int get_seq_number() const { return seq_number; }
+ modelclock_t get_seq_number() const { return seq_number; }
int get_value() const { return value; }
Node * get_node() const { return node; }
* saved on the NodeStack. */
Node *node;
- int seq_number;
+ modelclock_t seq_number;
/** The clock vector stored with this action; only needed if this
* action is a store release? */
ClockVector::ClockVector(ClockVector *parent, ModelAction *act)
{
num_threads = model->get_num_threads();
- clock = (int *)MYMALLOC(num_threads * sizeof(int));
+ clock = (modelclock_t *)MYMALLOC(num_threads * sizeof(int));
memset(clock, 0, num_threads * sizeof(int));
if (parent)
- std::memcpy(clock, parent->clock, parent->num_threads * sizeof(int));
+ std::memcpy(clock, parent->clock, parent->num_threads * sizeof(modelclock_t));
if (act)
clock[id_to_int(act->get_tid())] = act->get_seq_number();
*/
void ClockVector::merge(ClockVector *cv)
{
- int *clk = clock;
+ modelclock_t *clk = clock;
bool resize = false;
ASSERT(cv != NULL);
if (cv->num_threads > num_threads) {
resize = true;
- clk = (int *)MYMALLOC(cv->num_threads * sizeof(int));
+ clk = (modelclock_t *)MYMALLOC(cv->num_threads * sizeof(modelclock_t));
}
/* Element-wise maximum */
int i;
printf("CV: (");
for (i = 0; i < num_threads; i++)
- printf("%2d%s", clock[i], (i == num_threads - 1) ? ")\n" : ", ");
+ printf("%2u%s", clock[i], (i == num_threads - 1) ? ")\n" : ", ");
}
#include "threads.h"
#include "mymemory.h"
+typedef unsigned int modelclock_t;
/* Forward declaration */
class ModelAction;
MEMALLOC
private:
/** @brief Holds the actual clock data, as an array. */
- int *clock;
+ modelclock_t *clock;
/** @brief The number of threads recorded in clock (i.e., its length). */
int num_threads;
}
/** @returns a sequence number for a new ModelAction */
-int ModelChecker::get_next_seq_num()
+modelclock_t ModelChecker::get_next_seq_num()
{
return ++used_sequence_numbers;
}
#include "libatomic.h"
#include "threads.h"
#include "action.h"
+#include "clockvector.h"
/* Forward declaration */
class NodeStack;
thread_id_t get_next_id();
int get_num_threads();
- int get_next_seq_num();
+ modelclock_t get_next_seq_num();
int switch_to_master(ModelAction *act);
MEMALLOC
private:
int next_thread_id;
- int used_sequence_numbers;
+ modelclock_t used_sequence_numbers;
int num_executions;
ModelAction * get_last_conflict(ModelAction *act);