Ricart-Agrawala Algorithm
Distributed Computing Assignment- BITS-WILP
Distributed Computing Assignment- BITS-WILP
Write a C program to implement Ricart-Agrawala algorithm for distributed mutual exclusion
RA.C
//RICART AGRAWALA ALGORITHM FOR MUTUAL EXCLUSION
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/times.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/wait.h>
#include <semaphore.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <signal.h>
#include <netdb.h>
#include <math.h>
#include <time.h>
#define BACKLOG 150 //Number of pending connections queue will hold
#define MAXDATASIZE 100 //Maximum number of bytes we can get at once
#define MAXLINE 750
#define TRUE 1
#define FALSE 0
#define noproc 4 //Total number of sites in the system
pthread_t tid1,tid2,tid3;
pthread_t proc1[5];
int argc1;
char argv1[50];
char argv[50];
int i;
int listenPort; //The process port on which it is recieving the messages
int count[25];
int serverFlag = 0; //flag to check if all servers/sites are ready
int requesttime[5]; //times at which the request message is sent
struct host //Structure to maintain the Id, Server name and Port number
{
int id;
char name[50];
int port;
};
struct host hs[20];
typedef struct myinfo1 //Structure to maintain my information
{
int id;
int portno;
char mac[50]; //machine or host name eg. net06
} myinfo;
myinfo my;
struct message //Structure that comtains the message exchanged
{
int id; //site ID
int procid; //Process ID
char type[10]; //Type of message sent
int seq_no; //sequence number of the process
int clock; //clock at which the message is sent
};
static int rfront=-1,rrear=-1; //The pointers for REQ_QUEUE
static int dfront=-1,drear=-1; //The pointers for the DEFER_QUEUe
static int pfront=-1,prear=-1; //The pointers for the PROCESS_QUEUE
struct message REQ_QUEUE[200]; //The REQUEST QUEUE
struct message DEFER_QUEUE[200]; //The DEFER QUEUE
int PROCESS_QUEUE[200]; //The PROCESS QUEUE
sem_t proc[5];
sem_t site;
//Mutex varialbes used to lock variuos globally shared variables
pthread_mutex_t sequence;
pthread_mutex_t inCS;
pthread_mutex_t reqCS;
pthread_mutex_t ccounter;
pthread_mutex_t replycnt;
pthread_mutex_t signals;
pthread_mutex_t types;
pthread_mutex_t clk;
pthread_mutex_t sending_mutex;
pthread_mutex_t sema;
pthread_mutex_t pqueue;
pthread_mutex_t processthd;
pthread_mutex_t counts;
pthread_mutex_t requestq;
pthread_mutex_t deferq;
pthread_mutex_t refront;
pthread_mutex_t rerear;
pthread_mutex_t defront;
pthread_mutex_t derear;
//The threads used in this program
void * recv_reply_thread ( void *);
void * recv_request_thread ( void *);
void * process_thread (void *);
void * processes (void *);
void send_reply(struct message *msg); //Function to send reply messages
void rinsert(struct message); //Request queue functions
void rdisplay(void);
struct message rdelete(void);
void dinsert(struct message); //Defer queue functions
void ddisplay(void);
struct message ddelete(void);
void pinsert(int); //Process queue functions
void pdisplay(void);
int pdelete();
void sigchld_handler(int s) // reap all dead processes
{
while(wait(NULL) > 0);
}
int me; //my id number
int our_seq_number=0; // My sequence number
int outstanding_reply_count = noproc-1; //outstanding reply count..Initially N-1
int counter=0; // counter for clock
int clockvalue=1;
int highest_sequence_number=0;
int counting=0;
int req_CS=0; // Request for the Critical section: initially FALSE
int in_CS=0; //Inside the Critical Section: initially FALSE
int SIGNAL;
int in; //to read if in CS
int req; // to read if req CS
int seqno; // to read seq no
int sendcount;
int recvcount;
int replycount; //to read current outstanding_reply_count
// SAVE CONNECTION - RECV
void saveconn(int sockfdr, int id, int counter)
{
int n;
FILE *file;
char line[MAXLINE];
struct message * msg, m;
pthread_mutex_lock(&sending_mutex);
msg = (struct message *)malloc(sizeof(struct message));
n = recv(sockfdr,(void *)msg,sizeof(struct message),0);
pthread_mutex_unlock(&sending_mutex);
m = *((struct message *)msg);
if(n == 0)
return;
else if(n < 0)
printf("saveconn(): read error\n");
else
printf("Site %d receiving %s from site %d with clock %d. \n",me,m.type,m.id,m.clock);
if(highest_sequence_number < m.seq_no)
{
highest_sequence_number = m.seq_no;
}
else
highest_sequence_number = highest_sequence_number;
pthread_mutex_lock(&clk);
clockvalue++;
if(clockvalue < (m.clock+1))
{
clockvalue = (m.clock+1);
}
pthread_mutex_unlock(&clk);
if(strcmp(m.type,"REQUEST") == 0)
{
printf("Recieving REQUEST message from site %d\n",m.id);
pthread_mutex_lock(&requestq);
rinsert(m);
rdisplay();
pthread_mutex_unlock(&requestq);
SIGNAL=1; //Process wakeup
}
else if(strcmp(m.type,"REPLY") == 0)
{
printf("Recieving REPLY message from site %d\n",m.id);
pthread_mutex_lock(&replycnt);
replycount++;
printf("CURRENT REPLYCOUNT : %d\n",replycount);
pthread_mutex_unlock(&replycnt);
}
else
{
printf("Improper message : message not received properly\n");
rdisplay();
}
}
// CLIENT CONNECTION - SEND
void cliconn(FILE *file,int sockfds, char *mac, int portno, int id,struct message *messg,int counter)
{
int n,i;
char sendline[400],recvline[MAXLINE + 1];
portno = my.portno;
pthread_mutex_lock(&clk);
messg->clock = clockvalue;
pthread_mutex_unlock(&clk);
if(send(sockfds,messg,sizeof(struct message),0) != sizeof(struct message))
printf("cliconn(): write error on socket\n");
printf("Site %d has sent the request message..\n",me);
}
// MAIN FUNCTION
int main(int argc, char **argv)
{
struct message *msg;
int s;
pthread_mutex_init(&sequence,NULL);
pthread_mutex_init(&inCS,NULL);
pthread_mutex_init(&reqCS,NULL);
pthread_mutex_init(&ccounter,NULL);
pthread_mutex_init(&replycnt,NULL);
pthread_mutex_init(&signals,NULL);
pthread_mutex_init(&types,NULL);
pthread_mutex_init(&clk,NULL);
pthread_mutex_init(&sending_mutex,NULL);
pthread_mutex_init(&sema,NULL);
pthread_mutex_init(&processthd,NULL);
pthread_mutex_init(&pqueue,NULL);
pthread_mutex_init(&counts,NULL);
pthread_mutex_init(&requestq,NULL);
pthread_mutex_init(&deferq,NULL);
pthread_mutex_init(&refront,NULL);
pthread_mutex_init(&rerear,NULL);
pthread_mutex_init(&defront,NULL);
pthread_mutex_init(&derear,NULL);
FILE *file;
file = fopen("config.txt", "r"); //Open the configuration file
if(file==NULL)
{
printf("Error: can't open file.\n");
return 1;
}
else
printf("File opened successfully.\n");
for(i=1;i<=noproc;i++)
{
fscanf(file,"%d",&hs[i].id);//Reading host info from config file
fscanf(file,"%s",hs[i].name);
fscanf(file,"%d",&hs[i].port);
}
argc1 = argc;
printf("%d %d",argc1,argc);
my.id = atoi(argv[1]);
me = my.id;
strcpy(my.mac,argv[2]);
char t[9];
strcpy(t,argv[3]);
my.portno = atoi(t);
listenPort = atoi(t);
printf("My ID is : %s My Port : %s and My IP %s\n",argv[1],argv[3],argv[2]);
printf("Configuration File\n"); //Printing the configuration file details
for(i=1;i<=noproc;i++)
{
printf("%d %s %d\n",hs[i].id,hs[i].name,hs[i].port);
}
fclose(file);
for(s=0;s<5;s++)
{
sem_init( &proc[s],0,0);
}
for(s=0;s<5;s++)
{
pthread_create( &proc1[s], NULL, &processes, (void *)s); //Creating processes in site
}
pthread_create( &tid3, NULL, &recv_request_thread, &msg); //Creating send thread
pthread_create( &tid2, NULL, &recv_reply_thread, &msg); //Creating recieve thread
pthread_create( &tid1, NULL, &process_thread, &msg); //Creating process thread
pthread_join( tid1, NULL ); //Join all process threads
pthread_join( tid2, NULL ); //Join all recieve reply threads
pthread_join( tid3, NULL ); //Join all recieve request threads
for(s=0;s<5;s++)
{
pthread_join( proc1[s], NULL); //Join all processes in the site
}
}
// RECIEVE REQUESTS THREAD
void * recv_request_thread(void *msg)
{
struct sockaddr_in their_addr; // Connector's address information
struct hostent *h;
int sockfds;
int pid;
int j;
int check, procid;
struct message m;
struct message tm;
m = *((struct message *)msg);
for(j=0;j<noproc; j++)
{
count[j];
}
if (argc1 != 4) //The command line should have the output file,machine name and
//my port address as the runtime parameters
{ //Error check the command line
fprintf(stderr,"usage: getip address\n");
exit(1);
}
int liveServers = 1; //Initialising number of live processes counting for itself
while(liveServers <= noproc)
//Checks for number of processes that are alive before sending
//the messages. It is similar to the initialization message sent
//to all the proceses
{
liveServers = 1;
int j;
for(j=1;j<=noproc;j++)
{
if ((sockfds = socket(AF_INET, SOCK_STREAM, 0)) == -1)
//Opens a connection to check for the live processes
{
perror("socket");
exit(1);
}
if ((h=gethostbyname(hs[j].name)) == NULL)
{
perror("gethostbyname");
exit(1);
}
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(hs[j].port);
their_addr.sin_addr = *((struct in_addr *)h->h_addr);
memset(&(their_addr.sin_zero), '\0', 8);
if (connect(sockfds, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) //Connects to the process
{
}
else
{
liveServers++;
//if connection is setup increments liveserver count by one
//everytime it extablishes a connection with a process
}
close(sockfds); //Connection closed after checking is done
}
}
serverFlag = 1; //When all processes are alive sets serverFlag to 1.
printf("\nALL SERVERS ARE READY!!! \n"); //Processes are ready to listen now.
/*REQUESTING ENTRY TO THE CRITICAL SECTION*/
while(1)
{
if(pfront==-1)
{
check = 0;
break;
}
else
check = 1;
if(check)
{
pthread_mutex_lock(&processthd);
procid = pdelete();
printf("SITE %d REQUESTING FOR CS..\n",me);
pthread_mutex_lock(&reqCS);
req_CS = 1;
req = req_CS;
pthread_mutex_unlock(&reqCS);
//preparing the structure for sending
m.id = me;
pthread_mutex_lock(&types);
strcpy(m.type,"REQUEST");
pthread_mutex_unlock(&types);
pthread_mutex_lock(&sequence);
our_seq_number = highest_sequence_number+1;
m.seq_no = our_seq_number;
pthread_mutex_unlock(&sequence);
for(i=1; i<=noproc; i++)
{
if(i == me) //Checking request not sending to myself
{
continue;
}
if ((h=gethostbyname(hs[i].name)) == NULL)
{
perror("gethostbyname");
exit(1);
}
if ((sockfds = socket(AF_INET, SOCK_STREAM, 0)) == -1)
//Opens socket to send messages
{
perror("socket");
exit(1);
}
their_addr.sin_family = AF_INET; // Host byte order
their_addr.sin_port = htons(hs[i].port); // Short,networbyteorder
their_addr.sin_addr = *((struct in_addr *)h->h_addr);
memset(&(their_addr.sin_zero), '\0', 8); // Zero the rest of the struct
sleep(1);
if (connect(sockfds, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
{
perror("connect in send thread\n");
exit(1);
}
printf("Clock value is updated to %d\n",clockvalue);
clockvalue=clockvalue+1;
m.clock=clockvalue;
requesttime[i]=m.clock;
counter = counter + 1;
requesttime[i]=m.clock;
printf("Site %d sending REQUEST for process %d to site %d with timestamp %d\n",me,procid,i,m.clock);
cliconn(stdin, sockfds,my.mac,my.portno,my.id,&m,counter);
close(sockfds);
}
printf("Waiting for reply from other sites...");
while(1)
{
if (replycount == outstanding_reply_count)
{
pthread_mutex_lock(&replycnt);
replycount=0;
pthread_mutex_unlock(&replycnt);
break;
}
else
sleep(2);
}
/*ENTERING THE CRITICAL SECTION*/
//Is entering inside the CS
pthread_mutex_lock(&inCS);
in_CS = 1;
in = in_CS;
pthread_mutex_unlock(&inCS);
//Is not requesting for CS again
pthread_mutex_lock(&reqCS);
req_CS = 0;
req = req_CS;
pthread_mutex_unlock(&reqCS);
sem_post(&proc[procid]);
sem_wait(&site);
//Entering CS
pthread_mutex_lock(&inCS);
in_CS = 0;
in = in_CS;
pthread_mutex_unlock(&inCS);
/*RELEASING THE CRITICAL SECTION*/
sendcount = 0;
// Pop from the defer queue
while(drear!=-1)
{
pthread_mutex_lock(&types);
strcpy(m.type,"REPLY"); //copy my node id and the message type
pthread_mutex_unlock(&types);
m.id = me;
pthread_mutex_lock(&deferq);
tm = ddelete(); //tm is the buffer in which the values are stored in message
pid = tm.id;
pthread_mutex_unlock(&deferq);
sendcount++;
printf("Send Reply Message count: %d\n",sendcount);
if ((h=gethostbyname(hs[pid].name)) == NULL)
{
perror("gethostbyname");
exit(1);
}
if ((sockfds = socket(AF_INET, SOCK_STREAM, 0)) == -1)
//Opens socket to send messages
{
perror("socket");
exit(1);
}
their_addr.sin_family = AF_INET; // Host byte order
their_addr.sin_port = htons(hs[pid].port); // Short,networbyteorder
their_addr.sin_addr = *((struct in_addr *)h->h_addr);
memset(&(their_addr.sin_zero), '\0', 8); // Zero the rest of the struct
sleep(1);
if (connect(sockfds, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
{
perror("connect in send thread\n");
//exit(1);
}
cliconn(stdin, sockfds,my.mac,my.portno,my.id,&m,0);
close(sockfds);
}
pthread_mutex_unlock(&processthd);
}
}
}
// RECIEVE REPLYS THREAD
void * recv_reply_thread(void *msg)
{
int sockfdr, new_fd; // Listen on sock_fd, new connection on new_fd
struct sockaddr_in my_addr; // My address information
struct sockaddr_in their_addr; // Connector's address information
int sin_size;
int yes=1;
FILE *file;
struct message m;
m = *((struct message *)msg);
if ((sockfdr = socket(AF_INET, SOCK_STREAM, 0)) == -1) //Opening socket connection
{
perror("socket"); // Checking for any in case if connection failed
exit(1);
}
if (setsockopt(sockfdr, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
{
perror("setsockopt");
exit(1);
}
my_addr.sin_family = AF_INET; // Host byte order
my_addr.sin_port = htons(listenPort); // Short, network byteorder
my_addr.sin_addr.s_addr = (INADDR_ANY); // Automatically fill with myIP
memset(&(my_addr.sin_zero), '\0', 8); // Zero the rest of the struct
if (bind(sockfdr, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)
{ // Bind to my address
perror("bind"); // Check for errors
exit(1);
}
if (listen(sockfdr, BACKLOG) == -1) // Listening from the other processes
{
perror("listen"); // Checking for errors
exit(1);
}
for(;;)
{
int numbytes;
char buf[MAXDATASIZE];
sin_size = sizeof(struct sockaddr_in);
if ((new_fd = accept(sockfdr, (struct sockaddr*)&their_addr, (socklen_t*)&sin_size)) == -1)
{
perror("In server accept");
continue;
}
else
{
saveconn(new_fd,my.id,counter);
close(new_fd);
}
}
}
// THE SITE CONTROLLER THREAD
void * processes(void *msg)
{
int pid,mycount;
pid = (int)msg;
for(mycount=1; mycount<=20 ; mycount++)
{
pthread_mutex_lock(&pqueue);
pinsert(pid);
counting++;
pdisplay();
pthread_mutex_unlock(&pqueue);
sem_wait(&proc[pid]);
//entering crictical section
printf("Starting CS execution at time : %ld\n",time(NULL));
printf("*********SITE %d PROCESS %d ENTERING THE CS*********\n",me,pid);
printf("*********INSIDE THE CS*********\n");
sleep(1);
printf("*********SITE %d PROCESS %d EXITING THE CS*********\n",me,pid);
printf("Exiting CS at time : %ld\n",time(NULL));
sem_post(&site);
printf("\nProcess %d is in CS for %d times\n",pid,mycount);
}
printf("*** Total Message count: %d ***\n",counting);
}
// THE PROCESSING THREAD
void * process_thread(void *msg)
{
int nodeseq;
int pid; //use it for ripping the process to b sent to
struct message m;
m = *((struct message *)msg);
while(1)
{
printf("Process thread starting to process requests..\n ");
sleep(3);
while(SIGNAL == 1)
{
pthread_mutex_lock(&refront);
while(1)
{
//pop data from the request queue
if(rfront!=-1)
{
rdisplay();
pthread_mutex_lock(&inCS);
in = in_CS;
pthread_mutex_unlock(&inCS);
pthread_mutex_lock(&reqCS);
req = req_CS;
pthread_mutex_unlock(&reqCS);
pid=REQ_QUEUE[rfront].id;
nodeseq = REQ_QUEUE[rfront].seq_no;
pthread_mutex_lock(&requestq);
m = rdelete();
pthread_mutex_unlock(&requestq);
if (in == 1)
{
printf("PROCESS ALREADY IN CS..So putting in defer queue.!!!\n");
pthread_mutex_lock(&deferq);
dinsert(m);
pthread_mutex_unlock(&deferq);
}
else if( in == 0)
{
if (req == 1)
{
printf("SITE %d REQUESTING FOR CS AS WELL..\nSo tie break..between %d and %d..!!\n",pid,me,pid);
pthread_mutex_lock(&sequence);
seqno = our_seq_number;
pthread_mutex_unlock(&sequence);
printf("Their seqno: %d My seqno: %d Their ID: %d My ID: %d\n",nodeseq,seqno,pid,me);
if ((nodeseq < seqno) || (nodeseq == seqno && pid < me))
{
m.id = pid;
m.seq_no = 0;
strcpy(m.type, "REPLY");
send_reply(&m); //send reply to that node with my structure (node id and type)
}
else
{
printf("@@@@@ I WIN @@@@@ \nNode %d get the priority...So put %d in the defer queue..!\n",me,pid);
pthread_mutex_lock(&deferq);
dinsert(m);
pthread_mutex_unlock(&deferq);
}
}
else
{
m.id = pid;
m.seq_no = 0;
strcpy(m.type, "REPLY");
send_reply(&m); //send reply to that node with my structure (node id and type)
}
}
else
{
sleep(5);
}
}
}
}
pthread_mutex_unlock(&refront);
pthread_mutex_lock(&signals);
SIGNAL = 0;
pthread_mutex_unlock(&signals);
}
}
// SEND REPLYS FUNCTION
void send_reply(struct message *msg)
{
struct sockaddr_in their_addr; // Connector's address information
struct hostent *h;
int sockfds;
int pid;
struct message m;
m = *((struct message *)msg);
pid =m.id;
pthread_mutex_lock(&types);
strcpy(m.type,"REPLY");
pthread_mutex_unlock(&types);
m.id = me;
if ((h=gethostbyname(hs[pid].name)) == NULL)
{
perror("gethostbyname");
exit(1);
}
if ((sockfds = socket(AF_INET, SOCK_STREAM, 0)) == -1)
//Opens socket to send messages
{
perror("socket");
exit(1);
}
their_addr.sin_family = AF_INET; // Host byte order
their_addr.sin_port = htons(hs[pid].port); // Short,networbyteorder
their_addr.sin_addr = *((struct in_addr *)h->h_addr);
memset(&(their_addr.sin_zero), '\0', 8); // Zero the rest of the struct
sleep(1);
if (connect(sockfds, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1)
{
perror("connect in send thread\n");
exit(1);
}
cliconn(stdin, sockfds,my.mac,my.portno,my.id,&m,0);
printf("Sending REPLY message from site %d to site %d\n",me,pid);
close(sockfds); //Socket closed after sending the message to the process
}
// THE REQUEST QUEUE
//REQUEST QUEUE INSERT
void rinsert(struct message temp)
{
printf("Inside the request queue insert..\n");
if(rfront==rrear)
{
rfront = 0;
rrear = 0;
}
printf("Inserting values in request queue..\n");
REQ_QUEUE[rrear].id = temp.id;
strcpy(REQ_QUEUE[rrear].type,temp.type);
REQ_QUEUE[rrear].seq_no = temp.seq_no;
REQ_QUEUE[rrear].clock = temp.clock;
rrear++;
}
//REQUEST QUEUE DISPLAY
void rdisplay()
{
int i;
if(rfront==-1)
printf("CAUTION: Request Queue is Empty..!!\n");
for(i=rfront;i<rrear;i++)
printf("%d %s %d %d\n",REQ_QUEUE[i].id,REQ_QUEUE[i].type,REQ_QUEUE[i].seq_no,REQ_QUEUE[i].clock);
}
//REQUEST QUEUE DELETE
struct message rdelete()
{
struct message tempvar;
printf("Inside request queue delete.. \n");
rdisplay();
if(rfront==-1)
{
printf("CAUTION: Request Queue Underflow !!\n");
exit(1);
}
else if(rfront==rrear-1)
{
tempvar.id = REQ_QUEUE[rfront].id;
strcpy(tempvar.type,REQ_QUEUE[rfront].type);
tempvar.seq_no = REQ_QUEUE[rfront].seq_no;
tempvar.clock = REQ_QUEUE[rfront].clock;
rfront = -1;
rrear = -1;
}
else
{
tempvar.id = REQ_QUEUE[rfront].id;
strcpy(tempvar.type,REQ_QUEUE[rfront].type);
tempvar.seq_no = REQ_QUEUE[rrear].seq_no;
tempvar.clock = REQ_QUEUE[rfront].clock;
rfront++;
}
return tempvar;
}
// THE DEFER QUEUE
//DEFER QUEUE INSERT
void dinsert(struct message temp)
{
printf("Inside the defer queue insert..\n");
if(dfront==drear)
{
dfront = 0;
drear = 0;
}
DEFER_QUEUE[drear].id = temp.id;
strcpy(REQ_QUEUE[drear].type,temp.type);
DEFER_QUEUE[drear].seq_no = temp.seq_no;
DEFER_QUEUE[drear].clock = temp.clock;
drear++;
}
//DEFER QUEUE DISPLAY
void ddisplay()
{
int i;
if(dfront==-1)
printf("Defer Queue is Empty..!!\n");
for(i=dfront;i<drear;i++)
printf("%d %s %d %d\n",DEFER_QUEUE[i].id,DEFER_QUEUE[i].type,DEFER_QUEUE[i].seq_no,DEFER_QUEUE[i].clock);
}
//DEFER QUEUE DELETE
struct message ddelete()
{
struct message tempvar;
printf("Inside the defer queue delete..\n");
ddisplay();
if(dfront==-1)
{
printf("CAUTION: Defer queue Underflow !!\n");
exit(1);
}
else if(dfront==drear-1)
{
tempvar.id = DEFER_QUEUE[dfront].id;
strcpy(tempvar.type,DEFER_QUEUE[dfront].type);
tempvar.seq_no = DEFER_QUEUE[drear].seq_no;
tempvar.clock = DEFER_QUEUE[dfront].clock;
dfront = -1;
drear = -1;
}
else
{
tempvar.id = DEFER_QUEUE[dfront].id;
strcpy(tempvar.type, DEFER_QUEUE[dfront].type);
tempvar.seq_no = DEFER_QUEUE[drear].seq_no;
tempvar.clock = DEFER_QUEUE[dfront].clock;
dfront++;
}
return tempvar;
}
// THE PROCESS QUEUE
//PROCESS QUEUE INSERT
void pinsert(int temp)
{
printf("Inside the process queue insert..\n");
if(pfront==prear)
{
pfront = 0;
prear = 0;
}
PROCESS_QUEUE[prear] = temp;
prear++;
}
//PROCESS QUEUE DISPLAY
void pdisplay()
{
int i;
if(pfront==-1)
printf("Process Queue is Empty\n");
for(i=pfront;i<prear;i++)
printf("%d \n",PROCESS_QUEUE[i]);
}
//PROCESS QUEUE DELETE
int pdelete()
{
int tempvar;
printf("Inside process queue delete..\n");
pdisplay();
if(pfront==-1)
{
printf("CAUTION: Process Queue Underflow !!\n");
exit(1);
}
else if(pfront==prear-1)
{
tempvar = PROCESS_QUEUE[pfront];
pfront = -1;
prear = -1;
}
else
{
tempvar = PROCESS_QUEUE[pfront];
pfront++;
}
return tempvar;
}
config.txt
1 localhost 5001
2 localhost 6001
3 localhost 7001
4 localhost 8001
Instructions:
* Sending and Recieving of messages are done in the same program. So we have to run
the same program on as many sites as needed. Suppose there are 4 sites, there should be 4 consoles/Terminals opened.
* The processes will not start execution until all processes are started. So please
make sure that all processes are strated correctly.
* raexe.exe is the executable.
* config.txt is the configuration file. Please make sure that the config.txt file
is in the same directory as that of RA.c
Output
Terminal1
coding@techlife ~
$ gcc -o raexe RA.c
RA.c: In function ‘main’:
RA.c:317:48: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
pthread_create( &proc1[s], NULL, &processes, (void *)s); //Creating processes in site
^
RA.c: In function ‘processes’:
RA.c:663:8: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
pid = (int)msg;
^
coding@techlife ~
$ ./raexe.exe 1 localhost 5001
File opened successfully.
4 4My ID is : 1 My Port : 5001 and My IP localhost
Configuration File
1 localhost 5001
2 localhost 6001
3 localhost 7001
4 localhost 8001
Inside the process queue insert..
0
Inside the process queue insert..
0
1
Inside the process queue insert..
0
1
2
Inside the process queue insert..
0
1
2
3
Inside the process queue insert..
0
1
2
3
4
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
ALL SERVERS ARE READY!!!
Inside process queue delete..
0
1
2
3
4
SITE 1 REQUESTING FOR CS..
Site 1 receiving REQUEST from site 2 with clock 2.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 2
Site 1 receiving REQUEST from site 3 with clock 2.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 2
3 REQUEST 1 2
Clock value is updated to 4
Site 1 sending REQUEST for process 0 to site 2 with timestamp 5
Site 1 has sent the request message..
Site 1 receiving REQUEST from site 4 with clock 2.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 2
3 REQUEST 1 2
4 REQUEST 1 2
Clock value is updated to 6
Site 1 sending REQUEST for process 0 to site 3 with timestamp 7
Site 1 has sent the request message..
2 REQUEST 1 2
3 REQUEST 1 2
4 REQUEST 1 2
Inside request queue delete..
2 REQUEST 1 2
3 REQUEST 1 2
4 REQUEST 1 2
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 2..!!
Their seqno: 1 My seqno: 1 Their ID: 2 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
3 REQUEST 1 2
4 REQUEST 1 2
Inside request queue delete..
3 REQUEST 1 2
4 REQUEST 1 2
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 3..!!
Their seqno: 1 My seqno: 1 Their ID: 3 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
4 REQUEST 1 2
Inside request queue delete..
4 REQUEST 1 2
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 4..!!
Their seqno: 1 My seqno: 1 Their ID: 4 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REPLY from site 2 with clock 12.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 1
Clock value is updated to 13
Site 1 sending REQUEST for process 0 to site 4 with timestamp 14
Site 1 has sent the request message..
Waiting for reply from other sites...Site 1 receiving REPLY from site 3 with clock 18.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 2
Site 1 receiving REPLY from site 4 with clock 17.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
Starting CS execution at time : 1509002837
2 0 2
*********SITE 1 PROCESS 0 ENTERING THE CS*********
3 0 2
*********INSIDE THE CS*********
4 1 2
Send Reply Message count: 1
*********SITE 1 PROCESS 0 EXITING THE CS*********
Exiting CS at time : 1509002839
Process 0 is in CS for 1 times
Inside the process queue insert..
1
2
3
4
0
Site 1 has sent the request message..
Inside the defer queue delete..
3 0 2
4 1 2
Send Reply Message count: 2
Site 1 has sent the request message..
Inside the defer queue delete..
4 1 2
Send Reply Message count: 3
Site 1 has sent the request message..
Inside process queue delete..
1
2
3
4
0
SITE 1 REQUESTING FOR CS..
Clock value is updated to 20
Site 1 sending REQUEST for process 1 to site 2 with timestamp 21
Site 1 has sent the request message..
Site 1 receiving REQUEST from site 2 with clock 23.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 2 23
2 REQUEST 2 23
Inside request queue delete..
2 REQUEST 2 23
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 2..!!
Their seqno: 2 My seqno: 2 Their ID: 2 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 24
Site 1 sending REQUEST for process 1 to site 3 with timestamp 25
Site 1 has sent the request message..
Site 1 receiving REPLY from site 2 with clock 23.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 1
Site 1 receiving REQUEST from site 3 with clock 27.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 2 27
3 REQUEST 2 27
Inside request queue delete..
3 REQUEST 2 27
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 3..!!
Their seqno: 2 My seqno: 2 Their ID: 3 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REPLY from site 3 with clock 28.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 2
Clock value is updated to 29
Site 1 sending REQUEST for process 1 to site 4 with timestamp 30
Site 1 has sent the request message..
Waiting for reply from other sites...Site 1 receiving REQUEST from site 4 with clock 32.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 2 32
4 REQUEST 2 32
Inside request queue delete..
4 REQUEST 2 32
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 4..!!
Their seqno: 2 My seqno: 2 Their ID: 4 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REPLY from site 4 with clock 33.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 3
Starting CS execution at time : 1509002846
*********SITE 1 PROCESS 1 ENTERING THE CS*********
*********INSIDE THE CS*********
Inside the defer queue delete..
2 2 23
3 2 27
4 2 32
Send Reply Message count: 1
*********SITE 1 PROCESS 1 EXITING THE CS*********
Exiting CS at time : 1509002848
Process 1 is in CS for 1 times
Inside the process queue insert..
2
3
4
0
1
Site 1 has sent the request message..
Inside the defer queue delete..
3 2 27
4 2 32
Send Reply Message count: 2
Site 1 has sent the request message..
Inside the defer queue delete..
4 2 32
Send Reply Message count: 3
Site 1 has sent the request message..
Inside process queue delete..
2
3
4
0
1
SITE 1 REQUESTING FOR CS..
Clock value is updated to 34
Site 1 sending REQUEST for process 2 to site 2 with timestamp 35
Site 1 has sent the request message..
Site 1 receiving REQUEST from site 2 with clock 39.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 3 39
2 REQUEST 3 39
Inside request queue delete..
2 REQUEST 3 39
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 2..!!
Their seqno: 3 My seqno: 3 Their ID: 2 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 40
Site 1 sending REQUEST for process 2 to site 3 with timestamp 41
Site 1 has sent the request message..
Site 1 receiving REPLY from site 2 with clock 39.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 1
Site 1 receiving REPLY from site 3 with clock 43.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 2
Clock value is updated to 44
Site 1 sending REQUEST for process 2 to site 4 with timestamp 45
Site 1 has sent the request message..
Waiting for reply from other sites...Site 1 receiving REQUEST from site 3 with clock 44.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 4 44
Inside request queue delete..
3 REQUEST 4 44
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 3..!!
Their seqno: 4 My seqno: 3 Their ID: 3 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REQUEST from site 4 with clock 48.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 3 48
Inside request queue delete..
4 REQUEST 3 48
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 4..!!
Their seqno: 3 My seqno: 3 Their ID: 4 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REPLY from site 4 with clock 48.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
2 3 39
3 4 44
4 3 48
Send Reply Message count: 1
Starting CS execution at time : 1509002855
*********SITE 1 PROCESS 2 ENTERING THE CS*********
*********INSIDE THE CS*********
*********SITE 1 PROCESS 2 EXITING THE CS*********
Exiting CS at time : 1509002856
Process 2 is in CS for 1 times
Inside the process queue insert..
3
4
0
1
2
Site 1 has sent the request message..
Inside the defer queue delete..
3 4 44
4 3 48
Send Reply Message count: 2
Site 1 has sent the request message..
Inside the defer queue delete..
4 3 48
Send Reply Message count: 3
Site 1 has sent the request message..
Inside process queue delete..
3
4
0
1
2
SITE 1 REQUESTING FOR CS..
Clock value is updated to 50
Site 1 sending REQUEST for process 3 to site 2 with timestamp 51
Site 1 has sent the request message..
Clock value is updated to 51
Site 1 sending REQUEST for process 3 to site 3 with timestamp 52
Site 1 has sent the request message..
Site 1 receiving REPLY from site 2 with clock 53.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 1
Site 1 receiving REQUEST from site 2 with clock 54.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 6 54
2 REQUEST 6 54
Inside request queue delete..
2 REQUEST 6 54
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 2..!!
Their seqno: 6 My seqno: 5 Their ID: 2 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 55
Site 1 sending REQUEST for process 3 to site 4 with timestamp 56
Site 1 has sent the request message..
Waiting for reply from other sites...Site 1 receiving REQUEST from site 4 with clock 58.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 5 58
4 REQUEST 5 58
Inside request queue delete..
4 REQUEST 5 58
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 4..!!
Their seqno: 5 My seqno: 5 Their ID: 4 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REPLY from site 3 with clock 58.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 2
Site 1 receiving REPLY from site 4 with clock 58.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 3
Site 1 receiving REQUEST from site 3 with clock 59.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 7 59
3 REQUEST 7 59
Inside request queue delete..
3 REQUEST 7 59
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 3..!!
Their seqno: 7 My seqno: 5 Their ID: 3 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Starting CS execution at time : 1509002864
*********SITE 1 PROCESS 3 ENTERING THE CS*********
*********INSIDE THE CS*********
Inside the defer queue delete..
2 6 54
4 5 58
3 7 59
Send Reply Message count: 1
*********SITE 1 PROCESS 3 EXITING THE CS*********
Exiting CS at time : 1509002866
Process 3 is in CS for 1 times
Inside the process queue insert..
4
0
1
2
3
Site 1 has sent the request message..
Inside the defer queue delete..
4 5 58
3 7 59
Send Reply Message count: 2
Site 1 has sent the request message..
Inside the defer queue delete..
3 7 59
Send Reply Message count: 3
Site 1 has sent the request message..
Inside process queue delete..
4
0
1
2
3
SITE 1 REQUESTING FOR CS..
Clock value is updated to 62
Site 1 sending REQUEST for process 4 to site 2 with timestamp 63
Site 1 has sent the request message..
Clock value is updated to 63
Site 1 sending REQUEST for process 4 to site 3 with timestamp 64
Site 1 has sent the request message..
Site 1 receiving REQUEST from site 4 with clock 67.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 8 67
4 REQUEST 8 67
Inside request queue delete..
4 REQUEST 8 67
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 4..!!
Their seqno: 8 My seqno: 8 Their ID: 4 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 68
Site 1 sending REQUEST for process 4 to site 4 with timestamp 69
Site 1 has sent the request message..
Waiting for reply from other sites...Site 1 receiving REPLY from site 2 with clock 68.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 1
Site 1 receiving REPLY from site 4 with clock 72.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 2
Site 1 receiving REQUEST from site 2 with clock 74.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 9 74
2 REQUEST 9 74
Inside request queue delete..
2 REQUEST 9 74
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 2..!!
Their seqno: 9 My seqno: 8 Their ID: 2 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REQUEST from site 3 with clock 75.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 9 75
3 REQUEST 9 75
Inside request queue delete..
3 REQUEST 9 75
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 3..!!
Their seqno: 9 My seqno: 8 Their ID: 3 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Site 1 receiving REQUEST from site 4 with clock 82.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 10 82
4 REQUEST 10 82
Inside request queue delete..
4 REQUEST 10 82
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 1 and 4..!!
Their seqno: 10 My seqno: 8 Their ID: 4 My ID: 1
@@@@@ I WIN @@@@@
Node 1 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Terminal 2
coding@techlife ~
$ ./raexe.exe 2 localhost 6001
File opened successfully.
4 4My ID is : 2 My Port : 6001 and My IP localhost
Configuration File
1 localhost 5001
2 localhost 6001
3 localhost 7001
4 localhost 8001
Inside the process queue insert..
0
Inside the process queue insert..
0
1
Inside the process queue insert..
0
1
2
Inside the process queue insert..
0
1
2
3
Inside the process queue insert..
0
1
2
3
4
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
ALL SERVERS ARE READY!!!
Inside process queue delete..
0
1
2
3
4
SITE 2 REQUESTING FOR CS..
Clock value is updated to 1
Site 2 sending REQUEST for process 0 to site 1 with timestamp 2
Site 2 has sent the request message..
Site 2 receiving REQUEST from site 1 with clock 5.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 1 5
Clock value is updated to 6
Site 2 sending REQUEST for process 0 to site 3 with timestamp 7
Site 2 has sent the request message..
1 REQUEST 1 5
Inside request queue delete..
1 REQUEST 1 5
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 1..!!
Their seqno: 1 My seqno: 1 Their ID: 1 My ID: 2
Site 2 receiving REQUEST from site 3 with clock 9.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 1 9
Site 2 receiving REQUEST from site 4 with clock 3.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 1 9
4 REQUEST 1 3
Clock value is updated to 11
Site 2 sending REQUEST for process 0 to site 4 with timestamp 12
Site 2 has sent the request message..
Waiting for reply from other sites...Site 2 has sent the request message..
Sending REPLY message from site 2 to site 1
3 REQUEST 1 9
4 REQUEST 1 3
Inside request queue delete..
3 REQUEST 1 9
4 REQUEST 1 3
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 3..!!
Their seqno: 1 My seqno: 1 Their ID: 3 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
4 REQUEST 1 3
Inside request queue delete..
4 REQUEST 1 3
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 4..!!
Their seqno: 1 My seqno: 1 Their ID: 4 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 2 receiving REPLY from site 3 with clock 18.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
Site 2 receiving REPLY from site 4 with clock 17.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 2
Site 2 receiving REPLY from site 1 with clock 20.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
Starting CS execution at time : 1509002839
3 0 9
*********SITE 2 PROCESS 0 ENTERING THE CS*********
4 1 3
*********INSIDE THE CS*********
Send Reply Message count: 1
*********SITE 2 PROCESS 0 EXITING THE CS*********
Exiting CS at time : 1509002840
Process 0 is in CS for 1 times
Inside the process queue insert..
1
2
3
4
0
Site 2 has sent the request message..
Inside the defer queue delete..
4 1 3
Send Reply Message count: 2
Site 2 has sent the request message..
Inside process queue delete..
1
2
3
4
0
SITE 2 REQUESTING FOR CS..
Site 2 receiving REQUEST from site 1 with clock 21.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 2 21
1 REQUEST 2 21
Inside request queue delete..
1 REQUEST 2 21
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 1..!!
Their seqno: 2 My seqno: 2 Their ID: 1 My ID: 2
Clock value is updated to 22
Site 2 sending REQUEST for process 1 to site 1 with timestamp 23
Site 2 has sent the request message..
Site 2 has sent the request message..
Sending REPLY message from site 2 to site 1
Clock value is updated to 23
Site 2 sending REQUEST for process 1 to site 3 with timestamp 24
Site 2 has sent the request message..
Site 2 receiving REQUEST from site 3 with clock 29.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 2 29
Inside request queue delete..
3 REQUEST 2 29
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 3..!!
Their seqno: 2 My seqno: 2 Their ID: 3 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 30
Site 2 sending REQUEST for process 1 to site 4 with timestamp 31
Site 2 has sent the request message..
Waiting for reply from other sites...Site 2 receiving REPLY from site 3 with clock 29.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
Site 2 receiving REQUEST from site 4 with clock 34.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 2 34
Inside request queue delete..
4 REQUEST 2 34
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 4..!!
Their seqno: 2 My seqno: 2 Their ID: 4 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 2 receiving REPLY from site 4 with clock 35.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 2
Site 2 receiving REPLY from site 1 with clock 34.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
3 2 29
4 2 34
Send Reply Message count: 1
Starting CS execution at time : 1509002849
*********SITE 2 PROCESS 1 ENTERING THE CS*********
*********INSIDE THE CS*********
Site 2 has sent the request message..
Inside the defer queue delete..
4 2 34
Send Reply Message count: 2
*********SITE 2 PROCESS 1 EXITING THE CS*********
Exiting CS at time : 1509002850
Process 1 is in CS for 1 times
Inside the process queue insert..
2
3
4
0
1
Site 2 has sent the request message..
Inside process queue delete..
2
3
4
0
1
SITE 2 REQUESTING FOR CS..
Site 2 receiving REQUEST from site 1 with clock 35.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 3 35
1 REQUEST 3 35
Inside request queue delete..
1 REQUEST 3 35
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 1..!!
Their seqno: 3 My seqno: 3 Their ID: 1 My ID: 2
Clock value is updated to 38
Site 2 sending REQUEST for process 2 to site 1 with timestamp 39
Site 2 has sent the request message..
Site 2 has sent the request message..
Sending REPLY message from site 2 to site 1
Clock value is updated to 39
Site 2 sending REQUEST for process 2 to site 3 with timestamp 40
Site 2 has sent the request message..
Clock value is updated to 40
Site 2 sending REQUEST for process 2 to site 4 with timestamp 41
Site 2 has sent the request message..
Waiting for reply from other sites...Site 2 receiving REPLY from site 3 with clock 44.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
Site 2 receiving REQUEST from site 3 with clock 45.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 4 45
3 REQUEST 4 45
Inside request queue delete..
3 REQUEST 4 45
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 3..!!
Their seqno: 4 My seqno: 3 Their ID: 3 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Site 2 receiving REQUEST from site 4 with clock 49.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 3 49
4 REQUEST 3 49
Inside request queue delete..
4 REQUEST 3 49
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 4..!!
Their seqno: 3 My seqno: 3 Their ID: 4 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 2 receiving REPLY from site 4 with clock 49.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 2
Site 2 receiving REPLY from site 1 with clock 50.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
3 4 45
4 3 49
Send Reply Message count: 1
Starting CS execution at time : 1509002858
*********SITE 2 PROCESS 2 ENTERING THE CS*********
*********INSIDE THE CS*********
*********SITE 2 PROCESS 2 EXITING THE CS*********
Exiting CS at time : 1509002859
Process 2 is in CS for 1 times
Inside the process queue insert..
3
4
0
1
2
Site 2 has sent the request message..
Inside the defer queue delete..
4 3 49
Send Reply Message count: 2
Site 2 receiving REQUEST from site 1 with clock 51.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 5 51
1 REQUEST 5 51
Inside request queue delete..
1 REQUEST 5 51
Site 2 has sent the request message..
Inside process queue delete..
3
4
0
1
2
SITE 2 REQUESTING FOR CS..
Site 2 has sent the request message..
Sending REPLY message from site 2 to site 1
Clock value is updated to 53
Site 2 sending REQUEST for process 3 to site 1 with timestamp 54
Site 2 has sent the request message..
Clock value is updated to 54
Site 2 sending REQUEST for process 3 to site 3 with timestamp 55
Site 2 has sent the request message..
Clock value is updated to 55
Site 2 sending REQUEST for process 3 to site 4 with timestamp 56
Site 2 has sent the request message..
Waiting for reply from other sites...Site 2 receiving REPLY from site 3 with clock 58.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
Site 2 receiving REQUEST from site 4 with clock 60.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 5 60
4 REQUEST 5 60
Inside request queue delete..
4 REQUEST 5 60
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 4..!!
Their seqno: 5 My seqno: 6 Their ID: 4 My ID: 2
Site 2 has sent the request message..
Sending REPLY message from site 2 to site 4
Site 2 receiving REQUEST from site 3 with clock 63.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 7 63
3 REQUEST 7 63
Inside request queue delete..
3 REQUEST 7 63
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 3..!!
Their seqno: 7 My seqno: 6 Their ID: 3 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Site 2 receiving REPLY from site 1 with clock 62.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 2
Site 2 receiving REPLY from site 4 with clock 66.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 3
Site 2 receiving REQUEST from site 1 with clock 63.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 8 63
1 REQUEST 8 63
Inside request queue delete..
1 REQUEST 8 63
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 1..!!
Their seqno: 8 My seqno: 6 Their ID: 1 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 1 in the defer queue..!
Inside the defer queue insert..
Inside the defer queue delete..
3 7 63
1 8 63
Send Reply Message count: 1
Starting CS execution at time : 1509002870
*********SITE 2 PROCESS 3 ENTERING THE CS*********
*********INSIDE THE CS*********
Site 2 has sent the request message..
Inside the defer queue delete..
1 8 63
Send Reply Message count: 2
*********SITE 2 PROCESS 3 EXITING THE CS*********
Exiting CS at time : 1509002871
Process 3 is in CS for 1 times
Inside the process queue insert..
4
0
1
2
3
Site 2 has sent the request message..
Inside process queue delete..
4
0
1
2
3
SITE 2 REQUESTING FOR CS..
Site 2 receiving REQUEST from site 4 with clock 72.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 8 72
4 REQUEST 8 72
Inside request queue delete..
4 REQUEST 8 72
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 4..!!
Their seqno: 8 My seqno: 9 Their ID: 4 My ID: 2
Clock value is updated to 73
Site 2 sending REQUEST for process 4 to site 1 with timestamp 74
Site 2 has sent the request message..
Site 2 has sent the request message..
Sending REPLY message from site 2 to site 4
Clock value is updated to 74
Site 2 sending REQUEST for process 4 to site 3 with timestamp 75
Site 2 has sent the request message..
Site 2 receiving REQUEST from site 3 with clock 77.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 9 77
3 REQUEST 9 77
Inside request queue delete..
3 REQUEST 9 77
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 3..!!
Their seqno: 9 My seqno: 9 Their ID: 3 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 78
Site 2 sending REQUEST for process 4 to site 4 with timestamp 79
Site 2 has sent the request message..
Waiting for reply from other sites...Site 2 receiving REPLY from site 3 with clock 77.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
Site 2 receiving REPLY from site 4 with clock 81.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 2
Site 2 receiving REQUEST from site 4 with clock 83.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 10 83
4 REQUEST 10 83
Inside request queue delete..
4 REQUEST 10 83
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 2 and 4..!!
Their seqno: 10 My seqno: 9 Their ID: 4 My ID: 2
@@@@@ I WIN @@@@@
Node 2 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Terminal 3
coding@techlife ~
$ ./raexe.exe 3 localhost 7001
File opened successfully.
4 4My ID is : 3 My Port : 7001 and My IP localhost
Configuration File
1 localhost 5001
2 localhost 6001
3 localhost 7001
4 localhost 8001
Inside the process queue insert..
0
Inside the process queue insert..
0
1
Inside the process queue insert..
0
1
2
Inside the process queue insert..
0
1
2
3
Inside the process queue insert..
0
1
2
3
4
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
Process thread starting to process requests..
ALL SERVERS ARE READY!!!
Inside process queue delete..
0
1
2
3
4
SITE 3 REQUESTING FOR CS..
Clock value is updated to 1
Site 3 sending REQUEST for process 0 to site 1 with timestamp 2
Site 3 has sent the request message..
Site 3 receiving REQUEST from site 2 with clock 7.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 7
Clock value is updated to 8
Site 3 sending REQUEST for process 0 to site 2 with timestamp 9
Site 3 has sent the request message..
Site 3 receiving REQUEST from site 1 with clock 7.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 7
1 REQUEST 1 7
2 REQUEST 1 7
1 REQUEST 1 7
Inside request queue delete..
2 REQUEST 1 7
1 REQUEST 1 7
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 2..!!
Their seqno: 1 My seqno: 1 Their ID: 2 My ID: 3
Clock value is updated to 10
Site 3 sending REQUEST for process 0 to site 4 with timestamp 11
Site 3 has sent the request message..
Waiting for reply from other sites...Site 3 receiving REQUEST from site 4 with clock 17.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 1 7
4 REQUEST 1 17
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 2
1 REQUEST 1 7
4 REQUEST 1 17
Inside request queue delete..
1 REQUEST 1 7
4 REQUEST 1 17
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 1..!!
Their seqno: 1 My seqno: 1 Their ID: 1 My ID: 3
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 1
4 REQUEST 1 17
Inside request queue delete..
4 REQUEST 1 17
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 1 My seqno: 1 Their ID: 4 My ID: 3
@@@@@ I WIN @@@@@
Node 3 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 3 receiving REPLY from site 4 with clock 17.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 1
Site 3 receiving REPLY from site 1 with clock 20.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 2
Site 3 receiving REPLY from site 2 with clock 21.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
4 1 17
Starting CS execution at time : 1509002842
Send Reply Message count: 1
*********SITE 3 PROCESS 0 ENTERING THE CS*********
*********INSIDE THE CS*********
Site 3 has sent the request message..
Inside process queue delete..
1
2
3
4
SITE 3 REQUESTING FOR CS..
*********SITE 3 PROCESS 0 EXITING THE CS*********
Exiting CS at time : 1509002843
Process 0 is in CS for 1 times
Inside the process queue insert..
2
3
4
0
Site 3 receiving REQUEST from site 1 with clock 25.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 2 25
Inside request queue delete..
1 REQUEST 2 25
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 1..!!
Their seqno: 2 My seqno: 2 Their ID: 1 My ID: 3
Clock value is updated to 26
Site 3 sending REQUEST for process 1 to site 1 with timestamp 27
Site 3 has sent the request message..
Site 3 receiving REQUEST from site 2 with clock 24.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 2 24
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 1
2 REQUEST 2 24
Inside request queue delete..
2 REQUEST 2 24
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 2..!!
Their seqno: 2 My seqno: 2 Their ID: 2 My ID: 3
Clock value is updated to 28
Site 3 sending REQUEST for process 1 to site 2 with timestamp 29
Site 3 has sent the request message..
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 2
Clock value is updated to 29
Site 3 sending REQUEST for process 1 to site 4 with timestamp 30
Site 3 has sent the request message..
Waiting for reply from other sites...Site 3 receiving REQUEST from site 4 with clock 36.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 2 36
Inside request queue delete..
4 REQUEST 2 36
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 2 My seqno: 2 Their ID: 4 My ID: 3
@@@@@ I WIN @@@@@
Node 3 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Site 3 receiving REPLY from site 4 with clock 36.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 1
Site 3 receiving REPLY from site 1 with clock 34.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 2
Site 3 receiving REPLY from site 2 with clock 37.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
4 2 36
Send Reply Message count: 1
Starting CS execution at time : 1509002852
*********SITE 3 PROCESS 1 ENTERING THE CS*********
*********INSIDE THE CS*********
Site 3 receiving REQUEST from site 1 with clock 41.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 3 41
Inside request queue delete..
1 REQUEST 3 41
*********SITE 3 PROCESS 1 EXITING THE CS*********
Exiting CS at time : 1509002853
Process 1 is in CS for 1 times
Inside the process queue insert..
2
3
4
0
1
Site 3 has sent the request message..
Inside process queue delete..
2
3
4
0
1
SITE 3 REQUESTING FOR CS..
Site 3 receiving REQUEST from site 2 with clock 40.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 3 40
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 1
2 REQUEST 3 40
Inside request queue delete..
2 REQUEST 3 40
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 2..!!
Their seqno: 3 My seqno: 4 Their ID: 2 My ID: 3
Clock value is updated to 43
Site 3 sending REQUEST for process 2 to site 1 with timestamp 44
Site 3 has sent the request message..
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 2
Clock value is updated to 44
Site 3 sending REQUEST for process 2 to site 2 with timestamp 45
Site 3 has sent the request message..
Clock value is updated to 45
Site 3 sending REQUEST for process 2 to site 4 with timestamp 46
Site 3 has sent the request message..
Waiting for reply from other sites...Site 3 receiving REQUEST from site 4 with clock 51.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 3 51
4 REQUEST 3 51
Inside request queue delete..
4 REQUEST 3 51
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 3 My seqno: 4 Their ID: 4 My ID: 3
Site 3 receiving REPLY from site 1 with clock 50.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 1
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 4
Site 3 receiving REPLY from site 2 with clock 52.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 2
Site 3 receiving REQUEST from site 1 with clock 52.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 5 52
Inside request queue delete..
1 REQUEST 5 52
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 1..!!
Their seqno: 5 My seqno: 4 Their ID: 1 My ID: 3
@@@@@ I WIN @@@@@
Node 3 get the priority...So put 1 in the defer queue..!
Inside the defer queue insert..
Site 3 receiving REPLY from site 4 with clock 56.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
Starting CS execution at time : 1509002862
1 5 52
*********SITE 3 PROCESS 2 ENTERING THE CS*********
Send Reply Message count: 1
*********INSIDE THE CS*********
Site 3 receiving REQUEST from site 2 with clock 55.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 6 55
Inside request queue delete..
2 REQUEST 6 55
*********SITE 3 PROCESS 2 EXITING THE CS*********
Exiting CS at time : 1509002863
Process 2 is in CS for 1 times
Inside the process queue insert..
3
4
0
1
2
Site 3 has sent the request message..
Inside process queue delete..
3
4
0
1
2
SITE 3 REQUESTING FOR CS..
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 2
Clock value is updated to 58
Site 3 sending REQUEST for process 3 to site 1 with timestamp 59
Site 3 has sent the request message..
Site 3 receiving REQUEST from site 4 with clock 61.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 5 61
Inside request queue delete..
4 REQUEST 5 61
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 5 My seqno: 7 Their ID: 4 My ID: 3
Clock value is updated to 62
Site 3 sending REQUEST for process 3 to site 2 with timestamp 63
Site 3 has sent the request message..
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 4
Clock value is updated to 63
Site 3 sending REQUEST for process 3 to site 4 with timestamp 64
Site 3 has sent the request message..
Waiting for reply from other sites...Site 3 receiving REPLY from site 1 with clock 62.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 1
Site 3 receiving REPLY from site 4 with clock 66.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 2
Site 3 receiving REQUEST from site 1 with clock 64.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 8 64
Inside request queue delete..
1 REQUEST 8 64
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 5 My seqno: 7 Their ID: 4 My ID: 3
Site 3 receiving REPLY from site 2 with clock 68.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 3
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 4
Inside process queue delete..
4
0
1
2
SITE 3 REQUESTING FOR CS..
Starting CS execution at time : 1509002872
*********SITE 3 PROCESS 3 ENTERING THE CS*********
*********INSIDE THE CS*********
Site 3 receiving REQUEST from site 4 with clock 73.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 8 73
Inside request queue delete..
4 REQUEST 8 73
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 8 My seqno: 9 Their ID: 4 My ID: 3
*********SITE 3 PROCESS 3 EXITING THE CS*********
Exiting CS at time : 1509002873
Process 3 is in CS for 1 times
Inside the process queue insert..
0
1
2
3
Clock value is updated to 74
Site 3 sending REQUEST for process 4 to site 1 with timestamp 75
Site 3 has sent the request message..
Site 3 receiving REQUEST from site 2 with clock 75.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 9 75
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 4
2 REQUEST 9 75
Inside request queue delete..
2 REQUEST 9 75
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 2..!!
Their seqno: 9 My seqno: 9 Their ID: 2 My ID: 3
Clock value is updated to 76
Site 3 sending REQUEST for process 4 to site 2 with timestamp 77
Site 3 has sent the request message..
Site 3 has sent the request message..
Sending REPLY message from site 3 to site 2
Clock value is updated to 77
Site 3 sending REQUEST for process 4 to site 4 with timestamp 78
Site 3 has sent the request message..
Waiting for reply from other sites...Site 3 receiving REPLY from site 4 with clock 81.
Recieving REPLY message from site 4
CURRENT REPLYCOUNT : 1
Site 3 receiving REQUEST from site 4 with clock 84.
Recieving REQUEST message from site 4
Inside the request queue insert..
Inserting values in request queue..
4 REQUEST 10 84
Inside request queue delete..
4 REQUEST 10 84
SITE 4 REQUESTING FOR CS AS WELL..
So tie break..between 3 and 4..!!
Their seqno: 10 My seqno: 9 Their ID: 4 My ID: 3
@@@@@ I WIN @@@@@
Node 3 get the priority...So put 4 in the defer queue..!
Inside the defer queue insert..
Terminal 4
coding@techlife ~
$ ./raexe.exe 4 localhost 8001
File opened successfully.
4 4My ID is : 4 My Port : 8001 and My IP localhost
Configuration File
1 localhost 5001
2 localhost 6001
3 localhost 7001
4 localhost 8001
Inside the process queue insert..
0
Inside the process queue insert..
0
1
Inside the process queue insert..
0
1
2
Inside the process queue insert..
0
1
2
3
Inside the process queue insert..
0
1
2
3
4
Process thread starting to process requests..
ALL SERVERS ARE READY!!!
Inside process queue delete..
0
1
2
3
4
SITE 4 REQUESTING FOR CS..
Clock value is updated to 1
Site 4 sending REQUEST for process 0 to site 1 with timestamp 2
Site 4 has sent the request message..
Clock value is updated to 2
Site 4 sending REQUEST for process 0 to site 2 with timestamp 3
Site 4 has sent the request message..
Process thread starting to process requests..
Site 4 receiving REQUEST from site 2 with clock 12.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 12
Site 4 receiving REQUEST from site 1 with clock 14.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 12
1 REQUEST 1 14
Site 4 receiving REQUEST from site 3 with clock 11.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 1 12
1 REQUEST 1 14
3 REQUEST 1 11
Clock value is updated to 16
Site 4 sending REQUEST for process 0 to site 3 with timestamp 17
Site 4 has sent the request message..
Waiting for reply from other sites...2 REQUEST 1 12
1 REQUEST 1 14
3 REQUEST 1 11
Inside request queue delete..
2 REQUEST 1 12
1 REQUEST 1 14
3 REQUEST 1 11
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 2..!!
Their seqno: 1 My seqno: 1 Their ID: 2 My ID: 4
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 2
1 REQUEST 1 14
3 REQUEST 1 11
Inside request queue delete..
1 REQUEST 1 14
3 REQUEST 1 11
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 1..!!
Their seqno: 1 My seqno: 1 Their ID: 1 My ID: 4
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 1
3 REQUEST 1 11
Inside request queue delete..
3 REQUEST 1 11
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 3..!!
Their seqno: 1 My seqno: 1 Their ID: 3 My ID: 4
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 3
Site 4 receiving REPLY from site 1 with clock 20.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 1
Site 4 receiving REPLY from site 2 with clock 21.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 2
Site 4 receiving REPLY from site 3 with clock 22.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 3
Inside process queue delete..
Starting CS execution at time : 1509002844
1
*********SITE 4 PROCESS 0 ENTERING THE CS*********
2
*********INSIDE THE CS*********
3
4
SITE 4 REQUESTING FOR CS..
Site 4 receiving REQUEST from site 1 with clock 30.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 2 30
1 REQUEST 2 30
Inside request queue delete..
1 REQUEST 2 30
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 1..!!
Their seqno: 2 My seqno: 2 Their ID: 1 My ID: 4
*********SITE 4 PROCESS 0 EXITING THE CS*********
Exiting CS at time : 1509002845
Process 0 is in CS for 1 times
Inside the process queue insert..
2
3
4
0
Clock value is updated to 31
Site 4 sending REQUEST for process 1 to site 1 with timestamp 32
Site 4 has sent the request message..
Site 4 receiving REQUEST from site 2 with clock 31.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 2 31
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 1
2 REQUEST 2 31
Inside request queue delete..
2 REQUEST 2 31
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 2..!!
Their seqno: 2 My seqno: 2 Their ID: 2 My ID: 4
Clock value is updated to 33
Site 4 sending REQUEST for process 1 to site 2 with timestamp 34
Site 4 has sent the request message..
Site 4 receiving REQUEST from site 3 with clock 30.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 2 30
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 2
3 REQUEST 2 30
Inside request queue delete..
3 REQUEST 2 30
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 3..!!
Their seqno: 2 My seqno: 2 Their ID: 3 My ID: 4
Clock value is updated to 35
Site 4 sending REQUEST for process 1 to site 3 with timestamp 36
Site 4 has sent the request message..
Waiting for reply from other sites...Site 4 has sent the request message..
Sending REPLY message from site 4 to site 3
Site 4 receiving REPLY from site 1 with clock 34.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 1
Site 4 receiving REPLY from site 2 with clock 37.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 2
Site 4 receiving REPLY from site 3 with clock 42.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 3
Starting CS execution at time : 1509002853
*********SITE 4 PROCESS 1 ENTERING THE CS*********
*********INSIDE THE CS*********
Inside process queue delete..
2
3
4
0
SITE 4 REQUESTING FOR CS..
Site 4 receiving REQUEST from site 1 with clock 45.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 3 45
1 REQUEST 3 45
Inside request queue delete..
1 REQUEST 3 45
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 1..!!
Their seqno: 3 My seqno: 3 Their ID: 1 My ID: 4
Site 4 receiving REQUEST from site 2 with clock 41.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 3 41
*********SITE 4 PROCESS 1 EXITING THE CS*********
Exiting CS at time : 1509002854
Process 1 is in CS for 1 times
Inside the process queue insert..
3
4
0
1
Clock value is updated to 47
Site 4 sending REQUEST for process 2 to site 1 with timestamp 48
Site 4 has sent the request message..
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 1
2 REQUEST 3 41
Inside request queue delete..
2 REQUEST 3 41
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 2..!!
Their seqno: 3 My seqno: 3 Their ID: 2 My ID: 4
Clock value is updated to 48
Site 4 sending REQUEST for process 2 to site 2 with timestamp 49
Site 4 has sent the request message..
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 2
Site 4 receiving REQUEST from site 3 with clock 46.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 4 46
3 REQUEST 4 46
Inside request queue delete..
3 REQUEST 4 46
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 3..!!
Their seqno: 4 My seqno: 3 Their ID: 3 My ID: 4
@@@@@ I WIN @@@@@
Node 4 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 50
Site 4 sending REQUEST for process 2 to site 3 with timestamp 51
Site 4 has sent the request message..
Waiting for reply from other sites...Site 4 receiving REPLY from site 3 with clock 53.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
Site 4 receiving REPLY from site 1 with clock 50.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 2
Site 4 receiving REPLY from site 2 with clock 53.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 3
Inside the defer queue delete..
3 4 46
Send Reply Message count: 1
Starting CS execution at time : 1509002861
*********SITE 4 PROCESS 2 ENTERING THE CS*********
*********INSIDE THE CS*********
*********SITE 4 PROCESS 2 EXITING THE CS*********
Exiting CS at time : 1509002862
Process 2 is in CS for 1 times
Inside the process queue insert..
3
4
0
1
2
Site 4 has sent the request message..
Inside process queue delete..
3
4
0
1
2
SITE 4 REQUESTING FOR CS..
Site 4 receiving REQUEST from site 1 with clock 56.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 5 56
1 REQUEST 5 56
Inside request queue delete..
1 REQUEST 5 56
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 1..!!
Their seqno: 5 My seqno: 5 Their ID: 1 My ID: 4
Clock value is updated to 57
Site 4 sending REQUEST for process 3 to site 1 with timestamp 58
Site 4 has sent the request message..
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 1
Site 4 receiving REQUEST from site 2 with clock 56.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 6 56
Inside request queue delete..
2 REQUEST 6 56
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 2..!!
Their seqno: 6 My seqno: 5 Their ID: 2 My ID: 4
@@@@@ I WIN @@@@@
Node 4 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
Clock value is updated to 59
Site 4 sending REQUEST for process 3 to site 2 with timestamp 60
Site 4 has sent the request message..
Clock value is updated to 60
Site 4 sending REQUEST for process 3 to site 3 with timestamp 61
Site 4 has sent the request message..
Waiting for reply from other sites...Site 4 receiving REPLY from site 2 with clock 61.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 1
Site 4 receiving REPLY from site 3 with clock 63.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 2
Site 4 receiving REQUEST from site 3 with clock 64.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 7 64
3 REQUEST 7 64
Inside request queue delete..
3 REQUEST 7 64
SITE 3 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 3..!!
Their seqno: 7 My seqno: 5 Their ID: 3 My ID: 4
@@@@@ I WIN @@@@@
Node 4 get the priority...So put 3 in the defer queue..!
Inside the defer queue insert..
Site 4 receiving REPLY from site 1 with clock 62.
Recieving REPLY message from site 1
CURRENT REPLYCOUNT : 3
Starting CS execution at time : 1509002867
*********SITE 4 PROCESS 3 ENTERING THE CS*********
*********INSIDE THE CS*********
Inside the defer queue delete..
2 6 56
3 7 64
Send Reply Message count: 1
*********SITE 4 PROCESS 3 EXITING THE CS*********
Exiting CS at time : 1509002868
Process 3 is in CS for 1 times
Inside the process queue insert..
4
0
1
2
3
Site 4 has sent the request message..
Inside the defer queue delete..
3 7 64
Send Reply Message count: 2
Site 4 has sent the request message..
Inside process queue delete..
4
0
1
2
3
SITE 4 REQUESTING FOR CS..
Clock value is updated to 66
Site 4 sending REQUEST for process 4 to site 1 with timestamp 67
Site 4 has sent the request message..
Site 4 receiving REQUEST from site 1 with clock 69.
Recieving REQUEST message from site 1
Inside the request queue insert..
Inserting values in request queue..
1 REQUEST 8 69
Site 4 receiving REPLY from site 3 with clock 69.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 1
1 REQUEST 8 69
Inside request queue delete..
1 REQUEST 8 69
SITE 1 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 1..!!
Their seqno: 8 My seqno: 8 Their ID: 1 My ID: 4
Clock value is updated to 71
Site 4 sending REQUEST for process 4 to site 2 with timestamp 72
Site 4 has sent the request message..
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 1
Clock value is updated to 72
Site 4 sending REQUEST for process 4 to site 3 with timestamp 73
Site 4 has sent the request message..
Waiting for reply from other sites...Site 4 receiving REPLY from site 2 with clock 74.
Recieving REPLY message from site 2
CURRENT REPLYCOUNT : 2
Site 4 receiving REPLY from site 3 with clock 76.
Recieving REPLY message from site 3
CURRENT REPLYCOUNT : 3
Site 4 receiving REQUEST from site 2 with clock 79.
Recieving REQUEST message from site 2
Inside the request queue insert..
Inserting values in request queue..
2 REQUEST 9 79
Inside request queue delete..
2 REQUEST 9 79
SITE 2 REQUESTING FOR CS AS WELL..
So tie break..between 4 and 2..!!
Their seqno: 9 My seqno: 8 Their ID: 2 My ID: 4
@@@@@ I WIN @@@@@
Node 4 get the priority...So put 2 in the defer queue..!
Inside the defer queue insert..
Inside the defer queue delete..
Starting CS execution at time : 1509002875
2 9 79
*********SITE 4 PROCESS 4 ENTERING THE CS*********
Send Reply Message count: 1
*********INSIDE THE CS*********
Site 4 receiving REQUEST from site 3 with clock 78.
Recieving REQUEST message from site 3
Inside the request queue insert..
Inserting values in request queue..
3 REQUEST 9 78
3 REQUEST 9 78
Inside request queue delete..
3 REQUEST 9 78
*********SITE 4 PROCESS 4 EXITING THE CS*********
Exiting CS at time : 1509002876
Process 4 is in CS for 1 times
Inside the process queue insert..
0
1
2
3
4
Site 4 has sent the request message..
Inside process queue delete..
0
1
2
3
4
SITE 4 REQUESTING FOR CS..
Site 4 has sent the request message..
Sending REPLY message from site 4 to site 3
Clock value is updated to 81
Site 4 sending REQUEST for process 0 to site 1 with timestamp 82
Site 4 has sent the request message..
Clock value is updated to 82
Site 4 sending REQUEST for process 0 to site 2 with timestamp 83
Site 4 has sent the request message..
Clock value is updated to 83
Site 4 sending REQUEST for process 0 to site 3 with timestamp 84
Site 4 has sent the request message..
loda
ReplyDeleteraexe.exe: have u attached this file??
ReplyDelete