From 90432bf1b6327fb80b507a15213cbca7a137ac60 Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 6 Mar 2006 16:40:15 +0000 Subject: [PATCH] --- src/clock_cb.cc | 22 +++++++++++++++------- src/clock_cb.h | 1 + src/group.cc | 2 +- src/lowreceiver_cb.cc | 7 ++++--- src/timestamp.cc | 15 ++++++++++++--- src/timestamp.h | 2 ++ 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/clock_cb.cc b/src/clock_cb.cc index 8312abe..c639321 100644 --- a/src/clock_cb.cc +++ b/src/clock_cb.cc @@ -26,9 +26,11 @@ bool ClockCb::adjust(TimeStamp ts){ Glib::Mutex::Lock lock(_mutex); // si les conditions sont remplies, alors on peut modifier l'horloge - printf("ClockCb::adjust -- local index : %d\n", _cur_index ); - printf("ClockCb::adjust -- (emitter) stamp index : %d\n", ts.getIndex() ); - + printf("ClockCb::adjust -- Trying to adjust local (%d):\n", _cur_index); + this->val().display(); + printf("ClockCb::adjust -- ... with remote (%d)\n", ts.getIndex()); + ts.display(); + if (ts[emit_idx] == _ticks[emit_idx] + 1){ printf("ClockCb::adjust -- index TS_m[j] == TS_i[j] + 1 (FIFO property)\n"); @@ -56,13 +58,20 @@ bool ClockCb::adjust(TimeStamp ts){ return result; } +TimeStamp ClockCb::val(){ + TimeStamp ts(Protocol::TYPE_CBCAST, _cur_index); + // on push tous les ticks de l'horloge + for (int idx = 0; idx < _ticks.size(); idx++){ + ts.push_back (_ticks.at(idx)); + } + return ts; +} + + TimeStamp ClockCb::inc(){ // lock jusqu'a la fin de la fonction Glib::Mutex::Lock lock(_mutex); - printf("ClockCb::inc -- creating timestamp\n"); - // FIXME incrémenter le nombre de messages émis localement. - printf("ClockCb::inc -- cur_index from %d ", _ticks[_cur_index]); _ticks[_cur_index] = _ticks[_cur_index] + 1; printf("to %d\n", _ticks[_cur_index]); @@ -70,7 +79,6 @@ TimeStamp ClockCb::inc(){ TimeStamp ts(Protocol::TYPE_CBCAST, _cur_index); // on push tous les ticks de l'horloge for (int idx = 0; idx < _ticks.size(); idx++){ - printf ("ClockCb::ClockCb -- adding %d to timestamp\n", idx); ts.push_back (_ticks.at(idx)); } return ts; diff --git a/src/clock_cb.h b/src/clock_cb.h index 630e2d3..b588af4 100644 --- a/src/clock_cb.h +++ b/src/clock_cb.h @@ -14,6 +14,7 @@ class ClockCb : public Clock { virtual TimeStamp inc(); virtual bool adjust(TimeStamp stamp); + virtual TimeStamp val(); }; #endif diff --git a/src/group.cc b/src/group.cc index 21d609a..7a91d9d 100644 --- a/src/group.cc +++ b/src/group.cc @@ -87,7 +87,7 @@ void Group::broadcast(Message & msg){ it++; } - printf("Sending to %d\n", *it); + // printf("Sending to %d\n", *it); this->sendto(msg, *it); raList.remove(*it); diff --git a/src/lowreceiver_cb.cc b/src/lowreceiver_cb.cc index ccc4a5f..ef832b8 100644 --- a/src/lowreceiver_cb.cc +++ b/src/lowreceiver_cb.cc @@ -1,4 +1,5 @@ +#include "macros.h" #include "lowreceiver.h" void LowReceiver::manage_cbcast(Message * mesg) { @@ -6,8 +7,7 @@ void LowReceiver::manage_cbcast(Message * mesg) { static std::list fifo_deliverable; std::list::iterator iter; - printf("LowReceiver::manage_cbcast -- init\n"); - + // // identifiant = horloge + id_site_emeteur bool iAmTheEmitter = false; @@ -49,7 +49,8 @@ void LowReceiver::manage_cbcast(Message * mesg) { // supprimer le message de la liste des non-délivrés fifo_undelivered.erase(iter); foundDeliveredMsg = true; - printf("LowReceiver::manage_cbcast - found old deliverable...\n"); + printf("LowReceiver::manage_cbcast - %sfound old deliverable%s...\n", + COLOR_RED, COLOR_NORMAL); break; } } diff --git a/src/timestamp.cc b/src/timestamp.cc index cd3b419..a4bfafa 100644 --- a/src/timestamp.cc +++ b/src/timestamp.cc @@ -3,7 +3,7 @@ #include "timestamp.h" -#define DEBUG 1 +#define DEBUG 0 TimeStamp::TimeStamp(Protocol::Type type, short index){ _index = index; @@ -77,6 +77,7 @@ TimeStamp::TimeStamp(Protocol::Type type, char * raw, unsigned short raw_size){ pos_idx += 2; this->push_back(host_site_value); } + this->display(); } @@ -88,6 +89,13 @@ short TimeStamp::getIndex(){ return _index; } +void TimeStamp::display(){ + printf("TimeStamp::TimeStamp -- [ "); + for (int i = 0; i< this->size(); i++) + printf("%d ", this->at(i)); + printf("] from %d\n", _index); +} + char * TimeStamp::getRaw(){ int result_len = 0; char * result = NULL; @@ -142,8 +150,8 @@ char * TimeStamp::getRaw(){ host_clock_value = (*this)[idx]; net_clock_value = htons(host_clock_value); - //FIXME: if (DEBUG) - printf("TimeStamp::raw -- (CBCAST) clock_value %d -> %d\n", + if (DEBUG) + printf("TimeStamp::raw -- (CBCAST) clock_value %d -> %d\n", host_clock_value, net_clock_value); @@ -151,6 +159,7 @@ char * TimeStamp::getRaw(){ &net_clock_value, 2); // on fixe l'index dans le résultat } + this->display(); } break; default: diff --git a/src/timestamp.h b/src/timestamp.h index 0300604..5e0360b 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -20,6 +20,8 @@ class TimeStamp : public std::vector { short getIndex(); bool operator==(TimeStamp &stamp); + void TimeStamp::display(); + }; #endif