race condition?

"Matt Dew" <[email protected]>
Newsgroups gmane.linux.cluster.openmosix.devel
Message-ID <[email protected]>
Hi Tab, et al,
  What are the thoughts on the condition where the remote node sends a
syscall back to the home node and then receives a migrate home command
before the syscall response?   Is this the same problem (out of
sync-ness) that is causing the received -32 of 8 errors?

What is the best way to fix this?  
  1) Put in some ack/nack commands to ensure both remote and deputy are
in the same place?
  2) Open two ports. One for migration stuff and another for syscalls?
  3) Modify the functions to handle these cases?
  4) Add a counter field to the structs for bookkeeping; so both remote
and deputy know which response goes with which command and then merge
the calling functions?
  5) I'm simply not seeing the logic that is already supposed to handle
these?

I'm hoping it's 5, but if it's not; 
3 seems like a bad idea and will probably not scale well.  2 might scale
the best and be most robust??

The simple attached program shows it reliably.  It'll crash when trying
to migate back home.

Matt
loop.c (application/octet-stream, 1.6 KB)
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <string.h>

// 1. test self migration,
      // open file and keep open  - /proc/self/om/where
      // periodically read and write to self-migrate.
      // eventually close
int main(int argc, char **argv) 
{
int i;
unsigned long int j;
FILE *fp,*fp1;
char wherefile[]="/proc/self/om/where\0";
char node[]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
char node0[]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
char node1[]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
char migto[]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";

if (argc < 2) {
   printf("Usage: loop <node0> <node1>\n");
   printf("<node0> is usually home\n");
   exit(0);
}

      sprintf(node0, "%s", argv[1]);
      sprintf(node1, "%s", argv[2]);
      printf("Node0: !%s! -- Node1: !%s!\n", node0,node1);

      fp=fopen(wherefile, "r");
      fread(node, sizeof(char), sizeof(node), fp);
      printf("Starting on node: %s\n", node);
      fclose(fp);

for (i=0;i<100;i++) {
   
      for (j=0;j<1000000000;j++);
      for (i=0;i<sizeof(node);i++) node[i]='\0';
      fp=fopen(wherefile, "r");
      fread(node, sizeof(char), sizeof(node), fp);
      fclose(fp);

      node[strlen(node)-1]='\0';
      printf("On node: !%s!\n", node);
      if (!strncmp(node,node0,strlen(node0))) { // Migrate to other node
         strcpy(migto,node1);
      } else {
         strcpy(migto,node0);
      } 
      printf("Migrating to %s\n", migto);

      fp=fopen(wherefile, "w");
      fwrite(migto, sizeof(char), strlen(migto), fp);
      fclose(fp);

}
return 0;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.