Ejemplo n.º 1
0
int _tmain(int argc, _TCHAR* argv[])
{
    struct lfds611_stack_state* pStack = NULL;
    lfds611_stack_new(&pStack, 10000);

    ACE::init();

    SYSTEM_INFO si;
    GetSystemInfo(&si);

    int OptimalThreadCount =si.dwNumberOfProcessors;

    int pushThreadGroup = ACE_Thread_Manager::instance()->spawn_n(OptimalThreadCount, (ACE_THR_FUNC)PushThread, pStack, THR_NEW_LWP, ACE_DEFAULT_THREAD_PRIORITY, 1);
    int popThreadGroupID = ACE_Thread_Manager::instance()->spawn_n(OptimalThreadCount, (ACE_THR_FUNC)PopThread, pStack, THR_NEW_LWP, ACE_DEFAULT_THREAD_PRIORITY, 2);

    ACE_Thread_Manager::instance()->wait_grp(pushThreadGroup);

    g_bPushComplete = true;

    ACE_Thread_Manager::instance()->wait_grp(popThreadGroupID);

    ACE::fini();

    return 0;
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
int
msc_init (
  const msc_env_t envP,
  const int max_threadsP)
//------------------------------------------------------------------------------
{
  int                                     i;
  int                                     rv;
  void                                   *pointer_p;
  char                                    msc_filename[256];

  fprintf (stderr, "Initializing MSC logs\n");
  rv = snprintf (msc_filename, 256, "/tmp/openair.msc.%u.log", envP);   // TODO NAME

  if ((0 >= rv) || (256 < rv)) {
    fprintf (stderr, "Error in MSC log file name");
  }

  g_msc_fd = fopen (msc_filename, "w");
  AssertFatal (g_msc_fd != NULL, "Could not open MSC log file %s : %s", msc_filename, strerror (errno));
  rv = lfds611_stack_new (&g_msc_memory_stack_p, (lfds611_atom_t) max_threadsP + 2);

  if (0 >= rv) {
    AssertFatal (0, "lfds611_stack_new failed!\n");
  }

  rv = lfds611_queue_new (&g_msc_message_queue_p, (lfds611_atom_t) MSC_MAX_QUEUE_ELEMENTS);
  AssertFatal (rv, "lfds611_queue_new failed!\n");
  AssertFatal (g_msc_message_queue_p != NULL, "g_msc_message_queue_p is NULL!\n");
  msc_start_use ();

  for (i = 0; i < max_threadsP * 30; i++) {
    pointer_p = malloc (MSC_MAX_MESSAGE_LENGTH);
    AssertFatal (pointer_p, "malloc failed!\n");
    rv = lfds611_stack_guaranteed_push (g_msc_memory_stack_p, pointer_p);
    AssertFatal (rv, "lfds611_stack_guaranteed_push failed for item %u\n", i);
  }

  for (i = MIN_MSC_PROTOS; i < MAX_MSC_PROTOS; i++) {
    switch (i) {
    case MSC_NAS_UE:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_UE");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      break;


    case MSC_S1AP_ENB:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S1AP_ENB");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_GTPU_ENB:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "GTPU_ENB");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      break;

    case MSC_GTPU_SGW:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "GTPU_SGW");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if (envP == MSC_MME_GW)  {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_S1AP_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S1AP_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_MMEAPP_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "MME_APP");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_NAS_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      msc_log_declare_proto (i);
      break;

    case MSC_NAS_EMM_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_EMM");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_NAS_ESM_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_ESM");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_SP_GWAPP_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "SP_GW_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if (envP == MSC_MME_GW) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_S11_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S11_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if (envP == MSC_MME) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_S6A_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S6A");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_HSS:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "HSS");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    default:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "UNKNOWN");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }
    }
  }

  rv = itti_create_task (TASK_MSC, msc_task, NULL);
  AssertFatal (rv == 0, "Create task for MSC failed!\n");
  fprintf (stderr, "Initializing MSC logs Done\n");
  return 0;
}