예제 #1
0
void communicator::communicate()
{
  while(true)
  {
    //send or recv
    send_or_recv();
    //check_status
    int any_done=check_status();
    //post processing
    if(any_done!=-1)
       post_processing(any_done);
  }
}
void Chip_to_Chip_Direct_to_Hypervisor_Zero_Copy_Endpoint::open(int i) {
  
  Abstract_Zero_Copy_Command_Queue_Endpoint::open(i);
  
  channel_id = tilepci_channel_id( channel_type(), chip_index);
  if (channel_id == TILEPCI_EINVAL) {
    lprintf("tilepci_channel_id %s failed: specified channel is not legal\n", send_or_recv());
    fatal("");
  }
  char* msg;
  int r = tilepci_open_channel(&context, channel_id);
  if (!r) return; // success
  switch (errno) {
    case TILEPCI_ECHANNEL: msg = "TILEPCI_ECHANNEL: channel_id not legal"; break;
    case ENXIO: msg = "ENXIO: channel's link is down"; break;
    case EBUSY: msg = "EBUSY: channel currently in use by the device-file-based zero copy interface"; break;
    default: msg = "unknown error"; break;
  }
  lprintf("tilepci_open_channel failed: channel_id %d, chip_index %d, result %d, errno %d: %s\n", channel_id, chip_index, r, errno, msg);
  fatal("");
}
void Chip_to_Chip_Direct_to_Hypervisor_Zero_Copy_Endpoint::check_completion() {
  assert_always_eq(completion.tag, test_tag);
  assert_always(!completion.reset);
  static bool kvetched = false;
  if (!kvetched && completion.link_down) { kvetched = true; lprintf("link down on %d %s\n", chip_index, send_or_recv());  }
  // assert_always(!completion.link_down);
  assert_always_eq(completion.channel_id, command.channel_id);
}