This commit is contained in:
parent
28a4348365
commit
90432bf1b6
|
@ -26,9 +26,11 @@ bool ClockCb::adjust(TimeStamp ts){
|
||||||
Glib::Mutex::Lock lock(_mutex);
|
Glib::Mutex::Lock lock(_mutex);
|
||||||
// si les conditions sont remplies, alors on peut modifier l'horloge
|
// si les conditions sont remplies, alors on peut modifier l'horloge
|
||||||
|
|
||||||
printf("ClockCb::adjust -- local index : %d\n", _cur_index );
|
printf("ClockCb::adjust -- Trying to adjust local (%d):\n", _cur_index);
|
||||||
printf("ClockCb::adjust -- (emitter) stamp index : %d\n", ts.getIndex() );
|
this->val().display();
|
||||||
|
printf("ClockCb::adjust -- ... with remote (%d)\n", ts.getIndex());
|
||||||
|
ts.display();
|
||||||
|
|
||||||
if (ts[emit_idx] == _ticks[emit_idx] + 1){
|
if (ts[emit_idx] == _ticks[emit_idx] + 1){
|
||||||
printf("ClockCb::adjust -- index TS_m[j] == TS_i[j] + 1 (FIFO property)\n");
|
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;
|
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(){
|
TimeStamp ClockCb::inc(){
|
||||||
// lock jusqu'a la fin de la fonction
|
// lock jusqu'a la fin de la fonction
|
||||||
Glib::Mutex::Lock lock(_mutex);
|
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]);
|
printf("ClockCb::inc -- cur_index from %d ", _ticks[_cur_index]);
|
||||||
_ticks[_cur_index] = _ticks[_cur_index] + 1;
|
_ticks[_cur_index] = _ticks[_cur_index] + 1;
|
||||||
printf("to %d\n", _ticks[_cur_index]);
|
printf("to %d\n", _ticks[_cur_index]);
|
||||||
|
@ -70,7 +79,6 @@ TimeStamp ClockCb::inc(){
|
||||||
TimeStamp ts(Protocol::TYPE_CBCAST, _cur_index);
|
TimeStamp ts(Protocol::TYPE_CBCAST, _cur_index);
|
||||||
// on push tous les ticks de l'horloge
|
// on push tous les ticks de l'horloge
|
||||||
for (int idx = 0; idx < _ticks.size(); idx++){
|
for (int idx = 0; idx < _ticks.size(); idx++){
|
||||||
printf ("ClockCb::ClockCb -- adding %d to timestamp\n", idx);
|
|
||||||
ts.push_back (_ticks.at(idx));
|
ts.push_back (_ticks.at(idx));
|
||||||
}
|
}
|
||||||
return ts;
|
return ts;
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ClockCb : public Clock {
|
||||||
|
|
||||||
virtual TimeStamp inc();
|
virtual TimeStamp inc();
|
||||||
virtual bool adjust(TimeStamp stamp);
|
virtual bool adjust(TimeStamp stamp);
|
||||||
|
virtual TimeStamp val();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -87,7 +87,7 @@ void Group::broadcast(Message & msg){
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Sending to %d\n", *it);
|
// printf("Sending to %d\n", *it);
|
||||||
this->sendto(msg, *it);
|
this->sendto(msg, *it);
|
||||||
|
|
||||||
raList.remove(*it);
|
raList.remove(*it);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
#include "lowreceiver.h"
|
#include "lowreceiver.h"
|
||||||
|
|
||||||
void LowReceiver::manage_cbcast(Message * mesg) {
|
void LowReceiver::manage_cbcast(Message * mesg) {
|
||||||
|
@ -6,8 +7,7 @@ void LowReceiver::manage_cbcast(Message * mesg) {
|
||||||
static std::list<Message *> fifo_deliverable;
|
static std::list<Message *> fifo_deliverable;
|
||||||
|
|
||||||
std::list<Message *>::iterator iter;
|
std::list<Message *>::iterator iter;
|
||||||
printf("LowReceiver::manage_cbcast -- init\n");
|
//
|
||||||
|
|
||||||
// identifiant = horloge + id_site_emeteur
|
// identifiant = horloge + id_site_emeteur
|
||||||
bool iAmTheEmitter = false;
|
bool iAmTheEmitter = false;
|
||||||
|
|
||||||
|
@ -49,7 +49,8 @@ void LowReceiver::manage_cbcast(Message * mesg) {
|
||||||
// supprimer le message de la liste des non-délivrés
|
// supprimer le message de la liste des non-délivrés
|
||||||
fifo_undelivered.erase(iter);
|
fifo_undelivered.erase(iter);
|
||||||
foundDeliveredMsg = true;
|
foundDeliveredMsg = true;
|
||||||
printf("LowReceiver::manage_cbcast - found old deliverable...\n");
|
printf("LowReceiver::manage_cbcast - %sfound old deliverable%s...\n",
|
||||||
|
COLOR_RED, COLOR_NORMAL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "timestamp.h"
|
#include "timestamp.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 0
|
||||||
|
|
||||||
TimeStamp::TimeStamp(Protocol::Type type, short index){
|
TimeStamp::TimeStamp(Protocol::Type type, short index){
|
||||||
_index = index;
|
_index = index;
|
||||||
|
@ -77,6 +77,7 @@ TimeStamp::TimeStamp(Protocol::Type type, char * raw, unsigned short raw_size){
|
||||||
pos_idx += 2;
|
pos_idx += 2;
|
||||||
this->push_back(host_site_value);
|
this->push_back(host_site_value);
|
||||||
}
|
}
|
||||||
|
this->display();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +89,13 @@ short TimeStamp::getIndex(){
|
||||||
return _index;
|
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(){
|
char * TimeStamp::getRaw(){
|
||||||
int result_len = 0;
|
int result_len = 0;
|
||||||
char * result = NULL;
|
char * result = NULL;
|
||||||
|
@ -142,8 +150,8 @@ char * TimeStamp::getRaw(){
|
||||||
host_clock_value = (*this)[idx];
|
host_clock_value = (*this)[idx];
|
||||||
net_clock_value = htons(host_clock_value);
|
net_clock_value = htons(host_clock_value);
|
||||||
|
|
||||||
//FIXME: if (DEBUG)
|
if (DEBUG)
|
||||||
printf("TimeStamp::raw -- (CBCAST) clock_value %d -> %d\n",
|
printf("TimeStamp::raw -- (CBCAST) clock_value %d -> %d\n",
|
||||||
host_clock_value,
|
host_clock_value,
|
||||||
net_clock_value);
|
net_clock_value);
|
||||||
|
|
||||||
|
@ -151,6 +159,7 @@ char * TimeStamp::getRaw(){
|
||||||
&net_clock_value, 2); // on fixe l'index dans le résultat
|
&net_clock_value, 2); // on fixe l'index dans le résultat
|
||||||
|
|
||||||
}
|
}
|
||||||
|
this->display();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -20,6 +20,8 @@ class TimeStamp : public std::vector<short int> {
|
||||||
short getIndex();
|
short getIndex();
|
||||||
bool operator==(TimeStamp &stamp);
|
bool operator==(TimeStamp &stamp);
|
||||||
|
|
||||||
|
void TimeStamp::display();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue