summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvenkita <venkita@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-08-14 00:54:44 +0000
committervenkita <venkita@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-08-14 00:54:44 +0000
commitbc1e19109c52c684382fb5d9aff14b03fea42cfa (patch)
treeb952cc46312c39415f1b4e4f50886fe82b1470bd
parent45ae306eeb862760fcc71e55a82ac46403d52d06 (diff)
downloadATCD-bc1e19109c52c684382fb5d9aff14b03fea42cfa.tar.gz
ChangeLogTag: Wed Aug 13 19:48:17 2003 Venkita Subramonian <venkita@cs.wustl.edu>
-rw-r--r--ChangeLog18
-rw-r--r--Kokyu/Default_Dispatcher_Impl.cpp27
-rw-r--r--Kokyu/Default_Dispatcher_Impl.h6
-rw-r--r--Kokyu/Dispatcher_Impl.h7
-rw-r--r--Kokyu/Dispatcher_Impl.i10
-rw-r--r--Kokyu/Dispatcher_Task.cpp22
-rw-r--r--Kokyu/Kokyu.cpp8
-rw-r--r--Kokyu/Kokyu.h6
-rw-r--r--Kokyu/Kokyu_defs.cpp5
-rw-r--r--Kokyu/Kokyu_defs.h8
-rw-r--r--Kokyu/tests/EDF/test.cpp5
-rw-r--r--Kokyu/tests/FIFO/test.cpp5
12 files changed, 109 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 60f038addd6..a6f5649d469 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Wed Aug 13 19:48:17 2003 Venkita Subramonian <venkita@cs.wustl.edu>
+
+ * Kokyu/tests/FIFO/test.cpp:
+ * Kokyu/tests/EDF/test.cpp:
+ * Kokyu/Kokyu_defs.h:
+ * Kokyu/Kokyu_defs.cpp:
+ * Kokyu/Kokyu.h:
+ * Kokyu/Kokyu.cpp:
+ * Kokyu/Dispatcher_Task.cpp:
+ * Kokyu/Dispatcher_Impl.i:
+ * Kokyu/Dispatcher_Impl.h:
+ * Kokyu/Default_Dispatcher_Impl.h:
+ * Kokyu/Default_Dispatcher_Impl.cpp:
+
+ Separated activation of the dispatcher and setting up of
+ dispatching lanes. Added an activate () method to the dispatcher
+ and associated classes.
+
Wed Aug 13 23:43:24 UTC 2003 Don Hinton <dhinton@dresystems.com>
* ace/Bound_Ptr.i:
diff --git a/Kokyu/Default_Dispatcher_Impl.cpp b/Kokyu/Default_Dispatcher_Impl.cpp
index 31d1d3c9ac3..f5950efd8b9 100644
--- a/Kokyu/Default_Dispatcher_Impl.cpp
+++ b/Kokyu/Default_Dispatcher_Impl.cpp
@@ -11,14 +11,20 @@ ACE_RCSID(Kokyu, Default_Dispatcher_Impl, "$Id$")
namespace Kokyu
{
+
+Default_Dispatcher_Impl::Default_Dispatcher_Impl ()
+ : activated_ (0)
+{
+}
+
int
-Default_Dispatcher_Impl::init_i (const ConfigInfoSet& config_info_set)
+Default_Dispatcher_Impl::init_i (const Dispatcher_Attributes& attrs)
{
//create and init the dispatcher tasks here
//ACE_DEBUG ((LM_DEBUG, "entering init_t\n" ));
int size;
- size = config_info_set.size ();
+ size = attrs.config_info_set_.size ();
if (size == 0)
return -1;
@@ -33,7 +39,8 @@ Default_Dispatcher_Impl::init_i (const ConfigInfoSet& config_info_set)
//ACE_DEBUG ((LM_DEBUG, "task array auto_ptr set\n" ));
- ConfigInfoSet& config_set = const_cast<ConfigInfoSet&> (config_info_set);
+ ConfigInfoSet& config_set =
+ const_cast<ConfigInfoSet&> (attrs.config_info_set_);
ConfigInfoSet::ITERATOR iter(config_set);
int i=0;
@@ -51,16 +58,23 @@ Default_Dispatcher_Impl::init_i (const ConfigInfoSet& config_info_set)
//tasks_[i++].reset (task);
}
- this->activate ();
+ if (attrs.immediate_activation_ && !this->activated_)
+ {
+ this->activate_i ();
+ }
- curr_config_info_ = config_info_set;
+ curr_config_info_ = attrs.config_info_set_;
return 0;
}
int
-Default_Dispatcher_Impl::activate ()
+Default_Dispatcher_Impl::activate_i ()
{
int i;
+
+ if (this->activated_)
+ return 0;
+
for(i=0; i<ntasks_; ++i)
{
long flags = THR_BOUND | THR_SCHED_FIFO;
@@ -79,6 +93,7 @@ Default_Dispatcher_Impl::activate ()
}
}
+ this->activated_ = 1;
return 0;
}
diff --git a/Kokyu/Default_Dispatcher_Impl.h b/Kokyu/Default_Dispatcher_Impl.h
index b563302d6c8..95cedd10a07 100644
--- a/Kokyu/Default_Dispatcher_Impl.h
+++ b/Kokyu/Default_Dispatcher_Impl.h
@@ -37,10 +37,11 @@ namespace Kokyu
class Default_Dispatcher_Impl : public Dispatcher_Impl
{
public:
- int activate ();
+ Default_Dispatcher_Impl ();
private:
- int init_i (const ConfigInfoSet&);
+ int activate_i ();
+ int init_i (const Dispatcher_Attributes&);
int dispatch_i (const Dispatch_Command*,
const QoSDescriptor&);
int shutdown_i ();
@@ -51,6 +52,7 @@ namespace Kokyu
ACE_Auto_Array_Ptr<Dispatcher_Task_Auto_Ptr> tasks_;
int ntasks_;
ConfigInfoSet curr_config_info_;
+ int activated_;
};
class Shutdown_Task_Command : public Dispatch_Command
diff --git a/Kokyu/Dispatcher_Impl.h b/Kokyu/Dispatcher_Impl.h
index 32f083a54ee..ca0c907ae6d 100644
--- a/Kokyu/Dispatcher_Impl.h
+++ b/Kokyu/Dispatcher_Impl.h
@@ -35,7 +35,9 @@ namespace Kokyu
{
public:
/// Configure the dispatcher.
- int init (const ConfigInfoSet&);
+ int init (const Dispatcher_Attributes&);
+
+ int activate ();
/// dispatch a command (eg. event) based on the QoS supplied.
int dispatch (const Dispatch_Command*,
@@ -51,10 +53,11 @@ namespace Kokyu
//instead make them private and use the template method
//pattern - "Virtually Yours" article in CUJ Experts Forum
- virtual int init_i (const ConfigInfoSet&) =0;
+ virtual int init_i (const Dispatcher_Attributes&) =0;
virtual int dispatch_i (const Dispatch_Command*,
const QoSDescriptor&) =0;
virtual int shutdown_i () =0;
+ virtual int activate_i () =0;
};
} //end of namespace
diff --git a/Kokyu/Dispatcher_Impl.i b/Kokyu/Dispatcher_Impl.i
index a6c1d1ded3f..a1c31d16212 100644
--- a/Kokyu/Dispatcher_Impl.i
+++ b/Kokyu/Dispatcher_Impl.i
@@ -4,9 +4,9 @@ namespace Kokyu
{
ACE_INLINE
-int Dispatcher_Impl::init (const ConfigInfoSet& config_info)
+int Dispatcher_Impl::init (const Dispatcher_Attributes& attr)
{
- return init_i (config_info);
+ return init_i (attr);
}
ACE_INLINE
@@ -22,4 +22,10 @@ int Dispatcher_Impl::shutdown ()
return shutdown_i ();
}
+ACE_INLINE
+int Dispatcher_Impl::activate ()
+{
+ return activate_i ();
+}
+
}
diff --git a/Kokyu/Dispatcher_Task.cpp b/Kokyu/Dispatcher_Task.cpp
index e0dd4b2d9ad..3897c2e7941 100644
--- a/Kokyu/Dispatcher_Task.cpp
+++ b/Kokyu/Dispatcher_Task.cpp
@@ -53,6 +53,28 @@ int
Dispatcher_Task::svc (void)
{
int done = 0;
+
+ ACE_hthread_t thr_handle;
+ ACE_Thread::self (thr_handle);
+ int prio;
+
+ if (ACE_Thread::getprio (thr_handle, prio) == -1)
+ {
+ if (errno == ENOTSUP)
+ {
+ ACE_DEBUG((LM_DEBUG,
+ ACE_TEXT ("getprio not supported on this platform\n")
+ ));
+ return 0;
+ }
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("getprio failed")),
+ -1);
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "(%t) Dispatcher Thread started prio=%d\n", prio));
+
while (!done)
{
ACE_Message_Block *mb;
diff --git a/Kokyu/Kokyu.cpp b/Kokyu/Kokyu.cpp
index 54953431006..b79b78abec4 100644
--- a/Kokyu/Kokyu.cpp
+++ b/Kokyu/Kokyu.cpp
@@ -23,6 +23,10 @@ int Dispatcher::shutdown ()
return dispatcher_impl_->shutdown ();
}
+int Dispatcher::activate ()
+{
+ return dispatcher_impl_->activate ();
+}
void Dispatcher::implementation (Dispatcher_Impl* impl)
{
@@ -37,7 +41,7 @@ void Dispatcher::implementation (Dispatcher_Impl* impl)
Dispatcher_Auto_Ptr
Dispatcher_Factory::
-create_dispatcher(const ConfigInfoSet& config_info_set)
+create_dispatcher(const Dispatcher_Attributes& attrs)
{
Dispatcher* disp;
Dispatcher_Auto_Ptr nil_ptr((Dispatcher*)0);
@@ -46,7 +50,7 @@ create_dispatcher(const ConfigInfoSet& config_info_set)
ACE_NEW_RETURN (disp, Dispatcher, nil_ptr);
Dispatcher_Auto_Ptr disp_auto_ptr(disp);
disp->implementation (tmp);
- tmp->init (config_info_set);
+ tmp->init (attrs);
return disp_auto_ptr;
}
diff --git a/Kokyu/Kokyu.h b/Kokyu/Kokyu.h
index 1aae39ca08f..0d6c504b43c 100644
--- a/Kokyu/Kokyu.h
+++ b/Kokyu/Kokyu.h
@@ -59,6 +59,8 @@ namespace Kokyu
/// Supply this interface with an appripriate implementation.
void implementation (Dispatcher_Impl*);
+ int activate ();
+
/// Non virtual destructor. Read as <b><i>this class not available
/// for inheritance<i></b>.
~Dispatcher ();
@@ -91,8 +93,8 @@ namespace Kokyu
*
* @return Auto pointer to the dispatcher.
*/
- static Dispatcher_Auto_Ptr create_dispatcher (const ConfigInfoSet& config);
-
+ static Dispatcher_Auto_Ptr
+ create_dispatcher (const Dispatcher_Attributes& attr);
};
} //end of namespace
diff --git a/Kokyu/Kokyu_defs.cpp b/Kokyu/Kokyu_defs.cpp
index 030c1da88f6..ddbfd525080 100644
--- a/Kokyu/Kokyu_defs.cpp
+++ b/Kokyu/Kokyu_defs.cpp
@@ -13,4 +13,9 @@ namespace Kokyu
Dispatch_Command::~Dispatch_Command (void)
{
}
+
+ Dispatcher_Attributes::Dispatcher_Attributes ()
+ :immediate_activation_ (0)
+ {
+ }
}
diff --git a/Kokyu/Kokyu_defs.h b/Kokyu/Kokyu_defs.h
index c667920e78c..be1816b0b9f 100644
--- a/Kokyu/Kokyu_defs.h
+++ b/Kokyu/Kokyu_defs.h
@@ -76,6 +76,14 @@ namespace Kokyu
typedef ACE_Array<ConfigInfo> ConfigInfoSet;
+ struct Dispatcher_Attributes
+ {
+ Dispatcher_Attributes();
+ ConfigInfoSet config_info_set_;
+ int immediate_activation_;
+ };
+
+
struct QoSDescriptor
{
Priority_t preemption_priority_;
diff --git a/Kokyu/tests/EDF/test.cpp b/Kokyu/tests/EDF/test.cpp
index 24dc46310a5..17512bba588 100644
--- a/Kokyu/tests/EDF/test.cpp
+++ b/Kokyu/tests/EDF/test.cpp
@@ -58,8 +58,11 @@ int main (int,char**)
config_info[0].dispatching_type_ = Kokyu::DEADLINE_DISPATCHING;
ACE_DEBUG ((LM_DEBUG, "before create_dispatcher\n" ));
+
+ Kokyu::Dispatcher_Attributes attrs;
+ attrs.config_info_set_ = config_info;
auto_ptr<Kokyu::Dispatcher>
- disp (Kokyu::Dispatcher_Factory::create_dispatcher (config_info));
+ disp (Kokyu::Dispatcher_Factory::create_dispatcher (attrs));
ACE_ASSERT (disp.get() != 0);
diff --git a/Kokyu/tests/FIFO/test.cpp b/Kokyu/tests/FIFO/test.cpp
index 6697e704bdb..c349b6e1aec 100644
--- a/Kokyu/tests/FIFO/test.cpp
+++ b/Kokyu/tests/FIFO/test.cpp
@@ -61,8 +61,11 @@ int main (int,char**)
config_info[2].thread_priority_ = 0;
config_info[2].dispatching_type_ = Kokyu::FIFO_DISPATCHING;
+ Kokyu::Dispatcher_Attributes attrs;
+ attrs.config_info_set_ = config_info;
ACE_DEBUG ((LM_DEBUG, "before create_dispatcher\n" ));
- auto_ptr<Kokyu::Dispatcher> disp (Kokyu::Dispatcher_Factory::create_dispatcher (config_info));
+ auto_ptr<Kokyu::Dispatcher>
+ disp (Kokyu::Dispatcher_Factory::create_dispatcher (attrs));
ACE_ASSERT (disp.get() != 0);