From a8e1f2fbb48834dfe55c24bb54bc4acc92e9edc6 Mon Sep 17 00:00:00 2001 From: venkita Date: Thu, 2 Oct 2003 12:43:10 +0000 Subject: ChangeLogTag: Thu Oct 2 07:33:07 2003 Venkita Subramonian --- Kokyu/Default_Dispatcher_Impl.cpp | 18 +++++++++++--- Kokyu/Default_Dispatcher_Impl.i | 7 +----- Kokyu/Dispatcher_Task.cpp | 9 ++++--- Kokyu/Dispatcher_Task.h | 5 ++-- Kokyu/Dispatcher_Task.i | 7 ++++-- Kokyu/Kokyu_defs.cpp | 6 +++++ Kokyu/Kokyu_defs.h | 49 +++++++++++++++++++++++++++++++++------ Kokyu/Kokyu_defs.i | 17 ++++++++++---- Kokyu/Kokyu_dsrt.h | 27 +++++++-------------- Kokyu/tests/EDF/test.cpp | 6 ++++- Kokyu/tests/FIFO/test.cpp | 5 +++- 11 files changed, 106 insertions(+), 50 deletions(-) (limited to 'Kokyu') diff --git a/Kokyu/Default_Dispatcher_Impl.cpp b/Kokyu/Default_Dispatcher_Impl.cpp index f5950efd8b9..111a8581eaa 100644 --- a/Kokyu/Default_Dispatcher_Impl.cpp +++ b/Kokyu/Default_Dispatcher_Impl.cpp @@ -49,7 +49,7 @@ Default_Dispatcher_Impl::init_i (const Dispatcher_Attributes& attrs) { //ACE_DEBUG ((LM_DEBUG, "iter = %d\n", i)); Dispatcher_Task* task=0; - ACE_NEW_RETURN (task, Dispatcher_Task (*config), -1); + ACE_NEW_RETURN (task, Dispatcher_Task (*config, ACE_Thread_Manager::instance ()), -1); auto_ptr tmp_task_auto_ptr (task); tasks_[i++] = tmp_task_auto_ptr; //I couldn't use reset because MSVC++ auto_ptr does not have reset method. @@ -77,14 +77,14 @@ Default_Dispatcher_Impl::activate_i () for(i=0; iget_curr_config_info ().thread_priority_; if (this->tasks_[i]->activate (flags, 1, 1, priority) == -1) { - flags = THR_BOUND; + flags = THR_BOUND | THR_JOINABLE; priority = ACE_Sched_Params::priority_min (ACE_SCHED_OTHER, ACE_SCOPE_THREAD); if (this->tasks_[i]->activate (flags, 1, 1, priority) == -1) @@ -147,7 +147,19 @@ Default_Dispatcher_Impl::shutdown_i () tasks_[i]->enqueue (shutdown_cmd, qos_info); } + //wait for all tasks to exit + for (i=0; iwait (); + } + return 0; } +int +Shutdown_Task_Command::execute () +{ + return -1; +} + } diff --git a/Kokyu/Default_Dispatcher_Impl.i b/Kokyu/Default_Dispatcher_Impl.i index 2d10b58a2ac..bf1e76c3ce7 100644 --- a/Kokyu/Default_Dispatcher_Impl.i +++ b/Kokyu/Default_Dispatcher_Impl.i @@ -4,13 +4,8 @@ namespace Kokyu { ACE_INLINE Shutdown_Task_Command::Shutdown_Task_Command (ACE_Allocator *mb_allocator) + :Dispatch_Command(0,mb_allocator) { - ACE_UNUSED_ARG ((mb_allocator)); } -ACE_INLINE int -Shutdown_Task_Command::execute () -{ - return -1; -} } diff --git a/Kokyu/Dispatcher_Task.cpp b/Kokyu/Dispatcher_Task.cpp index 19ae12a3fa8..28ac43452ca 100644 --- a/Kokyu/Dispatcher_Task.cpp +++ b/Kokyu/Dispatcher_Task.cpp @@ -73,7 +73,7 @@ Dispatcher_Task::svc (void) -1); } - ACE_DEBUG ((LM_DEBUG, "(%t) Dispatcher Thread started prio=%d\n", prio)); + //ACE_DEBUG ((LM_DEBUG, "(%t) Dispatcher Thread started prio=%d\n", prio)); while (!done) { @@ -85,6 +85,8 @@ Dispatcher_Task::svc (void) ACE_ERROR ((LM_ERROR, "EC (%P|%t) getq error in Dispatching Queue\n")); + //ACE_DEBUG ((LM_DEBUG, "(%t) : next command got from queue\n")); + Dispatch_Queue_Item *qitem = ACE_dynamic_cast(Dispatch_Queue_Item*, mb); @@ -125,11 +127,12 @@ Dispatcher_Task::enqueue (const Dispatch_Command* cmd, ACE_Message_Block *mb = new (buf) Dispatch_Queue_Item (cmd, qos_info, - this->data_block_.duplicate (), + &(this->data_block_), + ACE_Message_Block::DONT_DELETE, this->allocator_); this->putq (mb); - + return 0; } diff --git a/Kokyu/Dispatcher_Task.h b/Kokyu/Dispatcher_Task.h index afe1ee96dca..8584af36e87 100644 --- a/Kokyu/Dispatcher_Task.h +++ b/Kokyu/Dispatcher_Task.h @@ -13,15 +13,13 @@ #ifndef DISPATCHER_TASK_H #define DISPATCHER_TASK_H #include /**/ "ace/pre.h" - #include "ace/Task.h" - +#include "ace/Lock_Adapter_T.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/Lock_Adapter_T.h" #include "Kokyu_defs.h" namespace Kokyu @@ -41,6 +39,7 @@ public: const Dispatch_Command* cmd, const QoSDescriptor& qos_info, ACE_Data_Block* data_block, + int flags, ACE_Allocator* mb_allocator =0); Dispatch_Command* command (); diff --git a/Kokyu/Dispatcher_Task.i b/Kokyu/Dispatcher_Task.i index 2f1047a0dd1..63246307178 100644 --- a/Kokyu/Dispatcher_Task.i +++ b/Kokyu/Dispatcher_Task.i @@ -6,7 +6,7 @@ ACE_INLINE Dispatcher_Task::Dispatcher_Task (const ConfigInfo& config_info, ACE_Thread_Manager* thr_manager) : ACE_Task (thr_manager), - allocator_ (0), + allocator_ (ACE_Allocator::instance ()), curr_config_info_ (config_info), deadline_msg_strategy_ (0, 0, 0x7FFFFFFFUL, 0x08000000UL ), //bits for static priority = 0 @@ -48,8 +48,11 @@ Dispatch_Queue_Item::Dispatch_Queue_Item ( const Dispatch_Command* cmd, const QoSDescriptor& qos_info, ACE_Data_Block *data_block, + int flags, ACE_Allocator* mb_allocator) - : ACE_Message_Block (data_block, 0, mb_allocator), + : ACE_Message_Block (data_block, + flags, + mb_allocator), command_ (cmd), qos_info_ (qos_info) { diff --git a/Kokyu/Kokyu_defs.cpp b/Kokyu/Kokyu_defs.cpp index f9afca619b8..8084195d8b8 100644 --- a/Kokyu/Kokyu_defs.cpp +++ b/Kokyu/Kokyu_defs.cpp @@ -18,6 +18,12 @@ namespace Kokyu :immediate_activation_ (0) { } + + DSRT_ConfigInfo::DSRT_ConfigInfo () + :sched_policy_ (ACE_SCHED_RR), + sched_scope_ (ACE_SCOPE_THREAD) + { + } } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) diff --git a/Kokyu/Kokyu_defs.h b/Kokyu/Kokyu_defs.h index d0c92496f17..b5cd071dcea 100644 --- a/Kokyu/Kokyu_defs.h +++ b/Kokyu/Kokyu_defs.h @@ -12,15 +12,15 @@ #define KOKYU_DEFS_H #include /**/ "ace/pre.h" #include "ace/Array.h" - - -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ #include "ace/Time_Value.h" #include "ace/Auto_Ptr.h" #include "ace/Message_Block.h" #include "ace/Sched_Params.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + #include "kokyu_export.h" namespace Kokyu @@ -85,7 +85,7 @@ namespace Kokyu }; - struct QoSDescriptor + struct Kokyu_Export QoSDescriptor { Priority_t preemption_priority_; Deadline_t deadline_; @@ -109,7 +109,11 @@ namespace Kokyu class Kokyu_Export Dispatch_Command { public: - Dispatch_Command(int dont_delete = 0); + Dispatch_Command(int dont_delete = 0, + ACE_Allocator *allocator = 0); + //dont_delete indicates whether this object needs to be deleted once processed. + //allocator indicates the ACE_Allocator, if any, from which this object was created. + //This same allocator has to be used for the deletion also /// Command callback virtual int execute () = 0; @@ -125,7 +129,38 @@ namespace Kokyu private: int dont_delete_; + ACE_Allocator *allocator_; + //if this object has to be deleted, then delete it using the allocator + //if one is present. }; + + enum DSRT_Sched_Type_t + { + DSRT_FP, + DSRT_MUF, + DSRT_MIF + }; + + enum DSRT_Dispatcher_Impl_t + { + DSRT_CV_BASED, + DSRT_OS_BASED + }; + + struct Kokyu_Export DSRT_ConfigInfo + { + //not used currently + DSRT_Sched_Type_t sched_strategy_; + + ACE_Sched_Params::Policy sched_policy_; + int sched_scope_; + + //type of implementation + DSRT_Dispatcher_Impl_t impl_type_; + + DSRT_ConfigInfo (); + }; + } //end of namespace //to satisfy ACE_Array diff --git a/Kokyu/Kokyu_defs.i b/Kokyu/Kokyu_defs.i index 8cd1a61a972..e87720db45c 100644 --- a/Kokyu/Kokyu_defs.i +++ b/Kokyu/Kokyu_defs.i @@ -5,8 +5,10 @@ namespace Kokyu { ACE_INLINE -Dispatch_Command::Dispatch_Command (int dont_delete) - :dont_delete_ (dont_delete) +Dispatch_Command::Dispatch_Command (int dont_delete, + ACE_Allocator *allocator) + :dont_delete_ (dont_delete), + allocator_ (allocator) { } @@ -19,9 +21,14 @@ int Dispatch_Command::can_be_deleted (void) const ACE_INLINE void Dispatch_Command::destroy (void) { - //@@what if it was allocated thru an allocator? - //may be this should be left as a pure virtual - delete this; + if (allocator_) + { + allocator_->free (this); + } + else + { + delete this; + } } } diff --git a/Kokyu/Kokyu_dsrt.h b/Kokyu/Kokyu_dsrt.h index 3e7496b0a74..ecbcd80d511 100644 --- a/Kokyu/Kokyu_dsrt.h +++ b/Kokyu/Kokyu_dsrt.h @@ -10,29 +10,18 @@ #ifndef KOKYU_DSRT_H #define KOKYU_DSRT_H -#include /**/ "ace/pre.h" +#include "ace/pre.h" #include "ace/Copy_Disabled.h" -#if !defined (ACE_LACKS_PRAGMA_ONCE) -# pragma once -#endif /* ACE_LACKS_PRAGMA_ONCE */ +//#if !defined (ACE_LACKS_PRAGMA_ONCE) +//# pragma once +//#endif /* ACE_LACKS_PRAGMA_ONCE */ #include "kokyu_export.h" #include "Kokyu_defs.h" namespace Kokyu { - enum DSRT_Sched_Type_t - { - DSRT_FP, - DSRT_MUF, - DSRT_MIF - }; - - struct DSRT_ConfigInfo - { - DSRT_Sched_Type_t sched_strategy_; - }; template class DSRT_Dispatcher_Impl; @@ -131,7 +120,7 @@ namespace Kokyu typedef typename QoSDesc::Importance_t Importance_t; int operator ()(const QoSDesc& qos1, - const QoSDesc& qos2); + const QoSDesc& qos2); }; /** @@ -148,7 +137,7 @@ namespace Kokyu typedef typename QoSDesc::Priority_t Priority_t; int operator ()(const QoSDesc& qos1, - const QoSDesc& qos2); + const QoSDesc& qos2); }; /** @@ -166,7 +155,7 @@ namespace Kokyu typedef typename QoSDesc::Time_t Time_t; int operator ()(const QoSDesc& qos1, - const QoSDesc& qos2); + const QoSDesc& qos2); }; @@ -184,5 +173,5 @@ namespace Kokyu #pragma implementation ("Kokyu_dsrt.cpp") #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ -#include /**/ "ace/post.h" +#include "ace/post.h" #endif /* KOKYU_DSRT_H */ diff --git a/Kokyu/tests/EDF/test.cpp b/Kokyu/tests/EDF/test.cpp index 17512bba588..b03c46a3713 100644 --- a/Kokyu/tests/EDF/test.cpp +++ b/Kokyu/tests/EDF/test.cpp @@ -93,7 +93,11 @@ int main (int,char**) disp->dispatch (&cmd3, qos3); printf("inserted 3\n"); - while(1){} + disp->activate (); + + disp->shutdown (); + + ACE_DEBUG ((LM_DEBUG, "after shutdown\n")); return 0; } diff --git a/Kokyu/tests/FIFO/test.cpp b/Kokyu/tests/FIFO/test.cpp index c349b6e1aec..52423dcf688 100644 --- a/Kokyu/tests/FIFO/test.cpp +++ b/Kokyu/tests/FIFO/test.cpp @@ -81,7 +81,10 @@ int main (int,char**) disp->dispatch (&cmd2, qos2); disp->dispatch (&cmd3, qos3); - while(1){} + disp->activate (); + disp->shutdown (); + + ACE_DEBUG ((LM_DEBUG, "after shutdown\n")); return 0; } -- cgit v1.2.1