~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to TAO/examples/Kokyu_dsrt_schedulers/muf_example/test_i.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// test_i.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp
2
 
 
3
 
#include "test_i.h"
4
 
#include "ace/High_Res_Timer.h"
5
 
#include "ace/Task.h"
6
 
#include "ace/ACE.h"
7
 
#include "tao/debug.h"
8
 
 
9
 
#if !defined(__ACE_INLINE__)
10
 
#include "test_i.i"
11
 
#endif /* __ACE_INLINE__ */
12
 
 
13
 
ACE_RCSID(MT_Server, test_i, "test_i.cpp,v 1.2 2003/10/08 13:26:32 venkita Exp")
14
 
 
15
 
CORBA::Long
16
 
Simple_Server_i::test_method (CORBA::Long exec_duration ACE_ENV_ARG_DECL)
17
 
    ACE_THROW_SPEC ((CORBA::SystemException))
18
 
{
19
 
  ACE_hthread_t thr_handle;
20
 
  ACE_Thread::self (thr_handle);
21
 
  int prio;
22
 
  int guid;
23
 
 
24
 
  ACE_OS::
25
 
    memcpy (&guid,
26
 
            this->current_->id (ACE_ENV_SINGLE_ARG_PARAMETER)->get_buffer (),
27
 
            sizeof (this->current_->id (ACE_ENV_SINGLE_ARG_PARAMETER)->length ()));
28
 
 
29
 
  ACE_High_Res_Timer timer;
30
 
  ACE_Time_Value elapsed_time;
31
 
 
32
 
  ACE_DEBUG ((LM_DEBUG, "Request in thread %t\n"));
33
 
 
34
 
  if (ACE_Thread::getprio (thr_handle, prio) == -1)
35
 
    {
36
 
      if (errno == ENOTSUP)
37
 
        {
38
 
          ACE_DEBUG((LM_DEBUG,
39
 
                     ACE_TEXT ("getprio not supported on this platform\n")
40
 
                     ));
41
 
          return 0;
42
 
        }
43
 
      ACE_ERROR_RETURN ((LM_ERROR,
44
 
                         ACE_TEXT ("%p\n"),
45
 
                         ACE_TEXT ("getprio failed")),
46
 
                        -1);
47
 
    }
48
 
 
49
 
  ACE_DEBUG ((LM_DEBUG, 
50
 
              "Request in thread %t, prio = %d,"
51
 
              "exec duration = %u\n", prio, exec_duration));
52
 
 
53
 
  static CORBA::ULong prime_number = 9619899;
54
 
 
55
 
  ACE_Time_Value compute_count_down_time (exec_duration, 0);
56
 
  ACE_Countdown_Time compute_count_down (&compute_count_down_time);
57
 
 
58
 
  //Applicable only for CV based implementations
59
 
  //yield every 1 sec
60
 
  ACE_Time_Value yield_interval (1,0);
61
 
 
62
 
  ACE_Time_Value yield_count_down_time (yield_interval);
63
 
  ACE_Countdown_Time yield_count_down (&yield_count_down_time);
64
 
  
65
 
  timer.start ();
66
 
  int j=0;
67
 
  while (compute_count_down_time > ACE_Time_Value::zero)
68
 
    {
69
 
      ACE::is_prime (prime_number,
70
 
                     2,
71
 
                     prime_number / 2);
72
 
      
73
 
      ++j;
74
 
 
75
 
#ifdef KOKYU_DSRT_LOGGING
76
 
      if (j%1000 == 0) 
77
 
        {
78
 
          ACE_DEBUG ((LM_DEBUG, 
79
 
            "(%t|%T) loop # = %d, load = %usec\n", j, exec_duration)); 
80
 
        }
81
 
#endif
82
 
      if (j%1000 == 0)
83
 
        {
84
 
          ACE_Time_Value run_time = ACE_OS::gettimeofday ();
85
 
          task_stats_.sample (ACE_UINT64 (run_time.msec ()), guid);
86
 
        }
87
 
      
88
 
      compute_count_down.update ();
89
 
 
90
 
      if (enable_yield_)
91
 
        {
92
 
          yield_count_down.update ();
93
 
          if (yield_count_down_time <= ACE_Time_Value::zero)
94
 
            {
95
 
              CORBA::Policy_var sched_param_policy = 
96
 
                CORBA::Policy::_duplicate (current_->
97
 
                                           scheduling_parameter(ACE_ENV_SINGLE_ARG_PARAMETER));
98
 
              
99
 
              const char * name = 0;
100
 
              
101
 
              CORBA::Policy_ptr implicit_sched_param = 0;
102
 
              current_->update_scheduling_segment (name,
103
 
                                                   sched_param_policy.in (),
104
 
                                                   implicit_sched_param
105
 
                                                   ACE_ENV_ARG_PARAMETER);
106
 
              yield_count_down_time = yield_interval;
107
 
              yield_count_down.start ();
108
 
            }
109
 
        }
110
 
    }
111
 
 
112
 
  timer.stop ();
113
 
  timer.elapsed_time (elapsed_time);
114
 
  
115
 
  ACE_DEBUG ((LM_DEBUG, 
116
 
              "Request processing in thread %t done, "
117
 
              "prio = %d, load = %d, elapsed time = %umsec\n", 
118
 
              prio, exec_duration, elapsed_time.msec () ));
119
 
  
120
 
  return exec_duration;
121
 
}
122
 
 
123
 
void
124
 
Simple_Server_i::shutdown (ACE_ENV_SINGLE_ARG_DECL)
125
 
    ACE_THROW_SPEC ((CORBA::SystemException))
126
 
{
127
 
  ACE_DEBUG ((LM_DEBUG, "shutdown request from client\n"));
128
 
  this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER);
129
 
}