This commit is contained in:
parent
28a4348365
commit
90432bf1b6
6 changed files with 35 additions and 14 deletions
|
@ -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;
|
||||
|
|
|
@ -14,6 +14,7 @@ class ClockCb : public Clock {
|
|||
|
||||
virtual TimeStamp inc();
|
||||
virtual bool adjust(TimeStamp stamp);
|
||||
virtual TimeStamp val();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Message *> fifo_deliverable;
|
||||
|
||||
std::list<Message *>::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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -20,6 +20,8 @@ class TimeStamp : public std::vector<short int> {
|
|||
short getIndex();
|
||||
bool operator==(TimeStamp &stamp);
|
||||
|
||||
void TimeStamp::display();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue