1 #include "Thread_Task.h"
2 #include "ace/Atomic_Op.h"
3 #include "ace/OS_NS_errno.h"
4 #include "ace/OS_NS_unistd.h"
6 ACE_Atomic_Op
<TAO_SYNCH_MUTEX
, long> guid_index
;
8 RTScheduling::Current::IdType
*
15 Thread_Task::activate_task (CORBA::ORB_ptr orb
)
19 this->orb_
= CORBA::ORB::_duplicate (orb
);
21 CORBA::Object_var current_obj
= this->orb_
->resolve_initial_references ("RTScheduler_Current");
23 this->current_
= RTScheduling::Current::_narrow (current_obj
.in ());
25 catch (const CORBA::Exception
& ex
)
27 ex
._tao_print_exception ("Exception:");
30 long flags
= THR_NEW_LWP
| THR_JOINABLE
;
31 if (this->ACE_Task
<ACE_SYNCH
>::activate (flags
,
34 if (ACE_OS::last_error () == EPERM
)
35 ACE_ERROR_RETURN ((LM_ERROR
,
36 ACE_TEXT ("Insufficient privilege to run this test.\n")),
39 active_thread_count_
= 4;
44 #if defined (THREAD_CANCELLED)
45 #undef THREAD_CANCELLED
46 #endif /* THREAD_CANCELLED */
53 const char * name
= 0;
54 CORBA::Policy_ptr sched_param
= 0;
55 CORBA::Policy_ptr implicit_sched_param
= 0;
57 //Start - Nested Scheduling Segment
58 this->current_
->begin_scheduling_segment ("Chamber of Secrets",
60 implicit_sched_param
);
63 RTScheduling::Current::IdType_var id
= this->current_
->id ();
64 ACE_OS::memcpy (&count
,
69 this->current_
->begin_scheduling_segment ("Potter",
71 implicit_sched_param
);
73 this->guid_
[guid_index
++] = id
.in ();
75 //Start - Nested Scheduling Segment
76 this->current_
->begin_scheduling_segment ("Harry",
78 implicit_sched_param
);
82 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
, -1);
83 RTScheduling::Current::NameList_var name_list
= this->current_
->current_scheduling_segment_names ();
86 "Scheduling Segments for DT %d :\n",
89 for (unsigned int i
= 0; i
< name_list
->length ();++i
)
92 "Scheduling Segment Name - %C\n",
93 (*name_list
) [i
].in ()));
99 this->current_
->end_scheduling_segment (name
);
100 // End - Nested Scheduling Segment
103 this->current_
->end_scheduling_segment (name
);
104 // End - Nested Scheduling Segment
106 this->current_
->end_scheduling_segment (name
);
108 catch (const CORBA::THREAD_CANCELLED
& )
110 ACE_DEBUG ((LM_DEBUG
,
111 "Distributable Thread Cancelled - Expected Exception\n"));
113 ACE_GUARD_RETURN (TAO_SYNCH_MUTEX
, ace_mon
, this->mutex_
, -1);
114 --active_thread_count_
;
115 if (active_thread_count_
== 0)
121 catch (const CORBA::Exception
& ex
)
123 ex
._tao_print_exception ("Caught exception:");