Ejemplo n.º 1
0
static void local_await(long *p, long value)
/*
  Wait for (*p == value)
*/
{
  long pval;
  long nspin = 0;
#ifdef NOSPIN
  long spinlim = 100;
  long waittim = 10000;
#else
  long spinlim = 100000000;
  long waittim = 100000;
#endif  
  extern void flush_send_q(void);

  while ((pval = local_flag(p)) != value) {

    if (pval && (pval != value)) {
      fprintf(stdout,"%2ld: invalid value=%ld, local_flag=%lx %ld\n", 
              TCGMSG_nodeid, value, (unsigned long)p, pval);
      fflush(stdout);
      exit(1);
    }
    nspin++;
    if((nspin&7)==0)flush_send_q();
    if (nspin < spinlim)
      Busy(100);
    else 
      USleep(waittim);
  }
}
Ejemplo n.º 2
0
/**
 * Return 0 if the message operation is incomplete.
 * Return 1 if the message operation is complete.
 */
long msg_status(long msgid)
{
    long node = NodeFromMsgID(msgid);
    SendQEntry *entry;
    long status = 1;

    flush_send_q();

    /* Attempt to find the msgid in the message q.  If it is not
       there then the send is complete */

    for (entry=TCGMSG_proc_info[node].sendq; entry; entry=(SendQEntry *) entry->next) {
        if (entry->msgid == msgid) {
            status = 0;
            break;
        }
    }

    return status;
}