コード例 #1
0
ファイル: client.c プロジェクト: boo1ean/servermy
int main(int argc, const char *argv[])
{
  // Init global server shared memory segment
  init_shared_memory_segment(); 

  // Init shared memory segment for current process's client
  if ((local_memory = init_client_shared_memory(getpid())) == NULL) {
    perror("Can't locate client memory");
    return SHM_CREAT_ERROR;
  }

  if (make_auth() == AUTH_FAIL) {
    printf("Auth error. Check if server is running.\n");
    return AUTH_FAIL;
  }
  
  clearScene();

  do {
    usleep(CLIENT_WAIT);
    if (send_sync_request() == _SYNC_DONE) {
      make_some_job();
    } else {
      printf("There is problem with server connection. Check if server is running.\n");
      return 1;
    }
  } while (1);

  return 0;
}
コード例 #2
0
ファイル: barrelfish_mp.c プロジェクト: schaars/kzimp
// Initialize resources for both the producer and the consumers
// First initialization function called
void IPC_initialize(int _nb_receivers, int _request_size)
{
  nb_receivers = _nb_receivers;

  request_size = _request_size;
  if (request_size < MIN_MSG_SIZE)
  {
    request_size = MIN_MSG_SIZE;
  }

  size_t urpc_msg_word = URPC_MSG_WORDS;
  size_t nb_messages = NB_MESSAGES;
  buffer_size = urpc_msg_word * 8 * nb_messages;
  connection_size = buffer_size * 2 + 2 * URPC_CHANNEL_SIZE;

  nb_cycles_send = 0;
  nb_cycles_recv = 0;
  nb_cycles_first_recv = 0;

  nb_messages_in_transit = 0;

  shared_areas = (void**) malloc(sizeof(void*) * nb_receivers);
  if (!shared_areas)
  {
    perror("Allocation error");
    exit(errno);
  }

  int i;
  for (i = 0; i < nb_receivers; i++)
  {
    shared_areas[i] = init_shared_memory_segment(
        "/tmp/barrelfish_message_passing_microbench", connection_size, 'a' + i);

#ifdef DEBUG
    printf("New shared area @ %p, len = %li\n", shared_areas[i],
        CONNECTION_SIZE);
#endif
  }
}