added some notes on unused_value flag to specify that this value does not guarantee an unused value...
#include "clockvector.h"
#include "common.h"
#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),
type(type),
order(order),
location(loc),
type_str = "unknown type";
}
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());
seq_number, id_to_int(tid), type_str, order, location, value);
if (reads_from)
printf(" Rf: %d", reads_from->get_seq_number());
#include "mymemory.h"
#include "clockvector.h"
#include "mymemory.h"
#include "clockvector.h"
+/** 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 */
/** @brief Represents an action type, identifying one of several types of
* ModelAction */
*/
class ModelAction {
public:
*/
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;
~ModelAction();
void print(void) const;
memory_order get_mo() const { return order; }
void * get_location() const { return location; }
modelclock_t get_seq_number() const { return seq_number; }
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; }
const ModelAction * get_reads_from() const { return reads_from; }
Node * get_node() const { return node; }
/** The value read or written (if RMW, then the value written). This
* should probably be something longer. */
/** The value read or written (if RMW, then the value written). This
* should probably be something longer. */
/** The action that this action reads from. Only valid for reads */
const ModelAction *reads_from;
/** The action that this action reads from. Only valid for reads */
const ModelAction *reads_from;
{
DBG();
model->switch_to_master(new ModelAction(ATOMIC_READ, order, obj));
{
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)
}
void atomic_init(struct atomic_object *obj, int value)
/* TODO: perform release/acquire synchronization here; include
* reads_from as ModelAction member? */
Thread *th = get_thread(curr->get_tid());
/* 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();
if (curr->is_read()) {
const ModelAction *reads_from = curr->get_node()->get_next_read_from();
value = reads_from->get_value();
#define __THREADS_H__
#include <ucontext.h>
#define __THREADS_H__
#include <ucontext.h>
#include "mymemory.h"
#include "libthreads.h"
#include "mymemory.h"
#include "libthreads.h"
* atomic read).
* @param value The value to return
*/
* 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,
/**
* Retrieve a return value for the last action in this thread. Used,
* be called from a user context.
* @return The value 'returned' by the action
*/
* 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();
friend void thread_startup();
* @see Thread::set_return_value()
* @see Thread::get_return_value()
*/
* @see Thread::set_return_value()
* @see Thread::get_return_value()
*/
+ uint64_t last_action_val;
};
Thread * thread_current();
};
Thread * thread_current();