Exemplo n.º 1
0
Arquivo: client.cpp Projeto: manut/TAO
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      int result =
        parse_args (argc, argv);
      if (result != 0)
        return result;

      // Thread Manager for managing task.
      ACE_Thread_Manager thread_manager;

      // Create task.
      Task task (thread_manager,
                 orb.in ());

      // Task activation flags.
      long flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        orb->orb_core ()->orb_params ()->thread_creation_flags ();

      // Activate task.
      result =
        task.activate (flags);
      if (result == -1)
        {
          if (errno == EPERM)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Cannot create thread with scheduling policy %s\n"
                                 "because the user does not have the appropriate privileges, terminating program....\n"
                                 "Check svc.conf options and/or run as root\n",
                                 sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
                                2);
            }
          else
            // Unexpected error.
            ACE_ASSERT (0);
        }

      // Wait for task to exit.
      result =
        thread_manager.wait ();
      ACE_ASSERT (result != -1);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception ("Exception caught");
      return -1;
    }

  return 0;
}
Exemplo n.º 2
0
Arquivo: 1-6.c Projeto: 1587/ltp
int main(void)
{
	pthread_attr_t attr;
	pthread_t th;
	struct params p;
	int ret;
	unsigned int i;

	ret = set_affinity_single();
	if (ret) {
		n_threads = get_ncpu();
		if (n_threads == -1) {
			printf("Cannot get number of CPUs\n");
			return PTS_UNRESOLVED;
		}
		printf("INFO: Affinity not supported, running %i threads.\n",
		       n_threads);
	} else {
		printf("INFO: Affinity works, will use only one thread.\n");
		n_threads = 1;
	}

	for (i = 0; i < ARRAY_SIZE(tcases); i++) {
		p.sched_policy = tcases[i].sched_policy;
		p.sched_priority = get_prio(&tcases[i]);

		init_attr(&attr, p.sched_policy, p.sched_priority);

		printf("INFO: Testing %s prio %i\n",
		       sched_policy_name(p.sched_policy), p.sched_priority);

		ret = pthread_create(&th, &attr, do_test, &p);
		if (ret) {
			fprintf(stderr, "pthread_create(): %s\n", strerror(ret));
			return PTS_UNRESOLVED;
		}

		pthread_join(th, NULL);

		pthread_attr_destroy(&attr);
	}

	printf("Test PASSED\n");
	return 0;
}
Exemplo n.º 3
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int result = 0;

  try
    {
      // Standard initialization:
      // parse arguments and get all the references (ORB,
      // RootPOA, RTORB, RTCurrent, POAManager).
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return -1;

      // Make sure we can support multiple priorities that are required
      // for this test.
      if (!check_supported_priorities (orb.in ()))
        return 2;

      // Thread Manager for managing task.
      ACE_Thread_Manager thread_manager;

      // Create task.
      Task task (thread_manager,
                 orb.in ());

      // Task activation flags.
      long flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        orb->orb_core ()->orb_params ()->thread_creation_flags ();

      // Activate task.
      result =
        task.activate (flags);
      if (result == -1)
        {
          if (errno == EPERM)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Cannot create thread with scheduling policy %s\n"
                                 "because the user does not have the appropriate privileges, terminating program....\n"
                                 "Check svc.conf options and/or run as root\n",
                                 sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
                                2);
            }
          else
            // Unexpected error.
            ACE_ERROR_RETURN ((LM_ERROR,
                                 "ERROR: Cannot create thread. errno = %d\n",
                                 ACE_ERRNO_GET),
                                -1);
        }

      // Wait for task to exit.
      result =
        thread_manager.wait ();
    }
  catch (const ::CORBA::Exception & ex)
    {
      ex._tao_print_exception(
                           "Exception caught:");
      return -1;
    }

  return result;
}
Exemplo n.º 4
0
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
  try
    {
      // Initialize the ORB, resolve references and parse arguments.

      // ORB.
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      // Parse arguments.
      if (parse_args (argc, argv) != 0)
        return -1;

      // Make sure we can support multiple priorities that are required
      // for this test.
      if (!check_supported_priorities (orb.in ()))
        return 2;

      // Thread Manager for managing task.
      ACE_Thread_Manager thread_manager;

      // Create task.
      Task task (thread_manager,
                 orb.in ());

      // Task activation flags.
      long flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        orb->orb_core ()->orb_params ()->thread_creation_flags ();

      // Activate task.
      int result =
        task.activate (flags);
      if (result == -1)
        {
          if (errno == EPERM)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Cannot create thread with scheduling policy %s\n"
                                 "because the user does not have the appropriate privileges, terminating program....\n"
                                 "Check svc.conf options and/or run as root\n",
                                 sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
                                2);
            }
          else
            // Unexpected error.
            ACE_ASSERT (0);
        }

      // Wait for task to exit.
      result =
        thread_manager.wait ();
      ACE_ASSERT (result != -1);
    }
  catch (const CORBA::Exception& ex)
    {
      ex._tao_print_exception (
        "Unexpected exception in MT_Client_Protocol_Priority test client:");
      return -1;
    }

  return 0;
}
Exemplo n.º 5
0
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    try
    {
        CORBA::ORB_var orb =
            CORBA::ORB_init (argc, argv);

        int result =
            parse_args (argc, argv);
        if (result != 0)
            return result;

        // Make sure we can support multiple priorities that are required
        // for this test.
        if (!check_supported_priorities (orb.in ()))
            return 2;

        // The following finds out the lowest priority for this
        // scheduling policy.  This will give us the biggest range on NT
        // since the default priority is 0 where as the lowest priority
        // is -15.
        int minimum_priority =
            ACE_Sched_Params::priority_min (orb->orb_core ()->orb_params ()->ace_sched_policy ());

        // Thread Manager for managing task.
        ACE_Thread_Manager thread_manager;

        // Create task.
        Task task (thread_manager,
                   orb.in ());

        // Task activation flags.
        long flags =
            THR_NEW_LWP |
            THR_JOINABLE |
            orb->orb_core ()->orb_params ()->thread_creation_flags ();

        // Activate task.
        result =
            task.activate (flags,
                           1, 0,
                           minimum_priority);
        if (result == -1)
        {
            if (errno == EPERM)
            {
                ACE_ERROR_RETURN ((LM_ERROR,
                                   "Cannot create thread with scheduling policy %C\n"
                                   "because the user does not have the appropriate privileges, terminating program....\n"
                                   "Check svc.conf options and/or run as root\n",
                                   sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
                                  2);
            }
            else
                // Unexpected error.
                ACE_ASSERT (0);
        }

        // Wait for task to exit.
        result =
            thread_manager.wait ();
        ACE_ASSERT (result != -1);
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Unexpected exception!");
        return -1;
    }

    return 0;
}
Exemplo n.º 6
0
Arquivo: client.cpp Projeto: manut/TAO
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
  int result = 0;
  try
    {
      // Register the interceptors to check for the RTCORBA
      // service contexts in the reply messages.
      PortableInterceptor::ORBInitializer_ptr temp_initializer;

      ACE_NEW_RETURN (temp_initializer,
                      Client_ORBInitializer,
                      -1);  // No exceptions yet!
      PortableInterceptor::ORBInitializer_var initializer =
        temp_initializer;

      PortableInterceptor::register_orb_initializer (initializer.in ());

      // Initialize and obtain reference to the Test object.
      CORBA::ORB_var orb =
        CORBA::ORB_init (argc, argv);

      if (parse_args (argc, argv) != 0)
        return -1;

      // Make sure we can support multiple priorities that are required
      // for this test.
      if (!check_supported_priorities (orb.in ()))
        return 2;

      // Thread Manager for managing task.
      ACE_Thread_Manager thread_manager;

      // Create task.
      Task task (thread_manager,
                 orb.in ());

      // Task activation flags.
      long flags =
        THR_NEW_LWP |
        THR_JOINABLE |
        orb->orb_core ()->orb_params ()->thread_creation_flags ();

      // Activate task.
      result =
        task.activate (flags);
      if (result == -1)
        {
          if (errno == EPERM)
            {
              ACE_ERROR_RETURN ((LM_ERROR,
                                 "Cannot create thread with scheduling policy %s\n"
                                 "because the user does not have the appropriate privileges, terminating program....\n"
                                 "Check svc.conf options and/or run as root\n",
                                 sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
                                2);
            }
          else
            // Unexpected error.
            ACE_ERROR_RETURN ((LM_ERROR,
                                 "ERROR: Cannot create thread. errno = %d\n",
                                 ACE_ERRNO_GET),
                                -1);
        }

      // Wait for task to exit.
      result =
        thread_manager.wait ();
    }
  catch (const CORBA::Exception & ae)
    {
      ae._tao_print_exception (
                           "Caught exception:");
      return -1;
    }

  return result;
}