From baf7877f639380a66770d974ad4312c42dda338b Mon Sep 17 00:00:00 2001 From: Brian Demsky Date: Mon, 16 Jul 2012 16:14:27 -0700 Subject: [PATCH] really should be using a type that is big enough for all commonly used data types... added some notes on unused_value flag to specify that this value does not guarantee an unused value... --- action.cc | 4 ++-- action.h | 11 +++++++---- libatomic.cc | 2 +- model.cc | 2 +- threads.h | 8 +++++--- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/action.cc b/action.cc index 39b0f7f6..adb31f8c 100644 --- a/action.cc +++ b/action.cc @@ -5,7 +5,7 @@ #include "clockvector.h" #include "common.h" -ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, int value) : +ModelAction::ModelAction(action_type_t type, memory_order order, void *loc, uint64_t value) : type(type), order(order), location(loc), @@ -180,7 +180,7 @@ void ModelAction::print(void) const type_str = "unknown type"; } - printf("(%3d) Thread: %-2d Action: %-13s MO: %d Loc: %14p Value: %-4d", + printf("(%3d) Thread: %-2d Action: %-13s MO: %d Loc: %14p Value: %-8u", seq_number, id_to_int(tid), type_str, order, location, value); if (reads_from) printf(" Rf: %d", reads_from->get_seq_number()); diff --git a/action.h b/action.h index 30c8a35b..36c72079 100644 --- a/action.h +++ b/action.h @@ -13,7 +13,10 @@ #include "mymemory.h" #include "clockvector.h" -#define VALUE_NONE -1 +/** Note that this value can be legitimately used by a program, and + hence by iteself does not indicate no value. */ + +#define VALUE_NONE 1234567890 /** @brief Represents an action type, identifying one of several types of * ModelAction */ @@ -38,7 +41,7 @@ class ClockVector; */ class ModelAction { public: - ModelAction(action_type_t type, memory_order order, void *loc, int value = VALUE_NONE); + ModelAction(action_type_t type, memory_order order, void *loc, uint64_t value = VALUE_NONE); ~ModelAction(); void print(void) const; @@ -47,7 +50,7 @@ public: memory_order get_mo() const { return order; } void * get_location() const { return location; } modelclock_t get_seq_number() const { return seq_number; } - int get_value() const { return value; } + uint64_t get_value() const { return value; } const ModelAction * get_reads_from() const { return reads_from; } Node * get_node() const { return node; } @@ -94,7 +97,7 @@ private: /** The value read or written (if RMW, then the value written). This * should probably be something longer. */ - int value; + uint64_t value; /** The action that this action reads from. Only valid for reads */ const ModelAction *reads_from; diff --git a/libatomic.cc b/libatomic.cc index 53173196..4d2ec553 100644 --- a/libatomic.cc +++ b/libatomic.cc @@ -13,7 +13,7 @@ int atomic_load_explicit(struct atomic_object *obj, memory_order order) { DBG(); model->switch_to_master(new ModelAction(ATOMIC_READ, order, obj)); - return thread_current()->get_return_value(); + return (int) thread_current()->get_return_value(); } void atomic_init(struct atomic_object *obj, int value) diff --git a/model.cc b/model.cc index 0bd9b61b..0c5733b5 100644 --- a/model.cc +++ b/model.cc @@ -278,7 +278,7 @@ void ModelChecker::check_current_action(void) /* TODO: perform release/acquire synchronization here; include * reads_from as ModelAction member? */ Thread *th = get_thread(curr->get_tid()); - int value = VALUE_NONE; + uint64_t value = VALUE_NONE; if (curr->is_read()) { const ModelAction *reads_from = curr->get_node()->get_next_read_from(); value = reads_from->get_value(); diff --git a/threads.h b/threads.h index 0f39a836..e7cd792a 100644 --- a/threads.h +++ b/threads.h @@ -6,6 +6,8 @@ #define __THREADS_H__ #include +#include + #include "mymemory.h" #include "libthreads.h" @@ -55,7 +57,7 @@ public: * atomic read). * @param value The value to return */ - void set_return_value(int value) { last_action_val = value; } + void set_return_value(uint64_t value) { last_action_val = value; } /** * Retrieve a return value for the last action in this thread. Used, @@ -63,7 +65,7 @@ public: * be called from a user context. * @return The value 'returned' by the action */ - int get_return_value() { return last_action_val; } + uint64_t get_return_value() { return last_action_val; } friend void thread_startup(); @@ -86,7 +88,7 @@ private: * @see Thread::set_return_value() * @see Thread::get_return_value() */ - int last_action_val; + uint64_t last_action_val; }; Thread * thread_current(); -- 2.34.1