diff options
Diffstat (limited to 'Kokyu')
-rw-r--r-- | Kokyu/DSRT_CV_Dispatcher_Impl_T.cpp | 280 | ||||
-rw-r--r-- | Kokyu/DSRT_CV_Dispatcher_Impl_T.h | 86 | ||||
-rw-r--r-- | Kokyu/DSRT_Direct_Dispatcher_Impl_T.cpp | 200 | ||||
-rw-r--r-- | Kokyu/DSRT_Direct_Dispatcher_Impl_T.h | 91 | ||||
-rw-r--r-- | Kokyu/DSRT_Dispatch_Item_T.h | 2 | ||||
-rw-r--r-- | Kokyu/DSRT_Dispatcher_Impl_T.cpp | 31 | ||||
-rw-r--r-- | Kokyu/DSRT_Dispatcher_Impl_T.h | 106 | ||||
-rw-r--r-- | Kokyu/DSRT_Sched_Queue_T.cpp | 79 | ||||
-rw-r--r-- | Kokyu/DSRT_Sched_Queue_T.h | 6 | ||||
-rw-r--r-- | Kokyu/Kokyu_dsrt.cpp | 42 | ||||
-rw-r--r-- | Kokyu/tests/DSRT_MIF/MIF.cpp | 12 | ||||
-rw-r--r-- | Kokyu/tests/DSRT_MIF/Makefile | 2 |
12 files changed, 746 insertions, 191 deletions
diff --git a/Kokyu/DSRT_CV_Dispatcher_Impl_T.cpp b/Kokyu/DSRT_CV_Dispatcher_Impl_T.cpp new file mode 100644 index 00000000000..ab5561d8ee3 --- /dev/null +++ b/Kokyu/DSRT_CV_Dispatcher_Impl_T.cpp @@ -0,0 +1,280 @@ +// $Id$ + +#ifndef DSRT_CV_DISPATCHER_IMPL_T_CPP +#define DSRT_CV_DISPATCHER_IMPL_T_CPP + +#include "DSRT_CV_Dispatcher_Impl_T.h" + +#if !defined (__ACE_INLINE__) +//#include "DSRT_CV_Dispatcher_Impl_T.i" +#endif /* __ACE_INLINE__ */ + +ACE_RCSID(Kokyu, DSRT_CV_Dispatcher_Impl_T, "$Id$") + +namespace Kokyu +{ + +/* +//@@VS: This is somehow not being recognized by MSVC, which results +//in a link error. For now, the definition has been moved to the .h +//file. Needs further investigation. + +template <class DSRT_Scheduler_Traits> +int Comparator_Adapter_Generator<DSRT_Scheduler_Traits>::MoreEligible:: +operator ()(const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item1, + const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item2) +{ + int rc = qos_comparator_ (item1->qos (), item2->qos ()); + + //more eligible + if (rc == 1) + return 1; + + //if equally eligible, then resolve tie with the creation time of + //the item + if (rc == 0 && item1->insertion_time () < item2->insertion_time ()) + return 1; + + return 0; +} +*/ + +template <class DSRT_Scheduler_Traits> +DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +DSRT_CV_Dispatcher_Impl (ACE_Sched_Params::Policy sched_policy, + int sched_scope) + :DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits> (sched_policy, sched_scope), + run_cond_ (run_cond_lock_) +{ +} + +template <class DSRT_Scheduler_Traits> int +DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +init_i (const DSRT_ConfigInfo&) +{ + return 0; +} + +template <class DSRT_Scheduler_Traits> +int DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +schedule_i (Guid_t id, const DSRT_QoSDescriptor& qos) +{ + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i enter\n")); +#endif + + DSRT_Dispatch_Item<DSRT_Scheduler_Traits>* item; + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + + if (ACE_OS::thr_setprio (thr_handle, blocked_prio_, sched_policy_) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio failed"))); + } + + ACE_NEW_RETURN (item, + DSRT_Dispatch_Item<DSRT_Scheduler_Traits> (id, qos), + -1); + item->thread_handle (thr_handle); + + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, synch_lock_, -1); + if (ready_queue_.insert (item) == -1) + return -1; + +#ifdef KOKYU_DSRT_LOGGING + ready_queue_.dump (); + + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i after ready_q.insert\n")); +#endif + + DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits> item_var; + + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, cond_guard, run_cond_lock_, -1); + ready_queue_.most_eligible (item_var); + + guard.release (); + + ACE_hthread_t most_eligible_thr_handle = item_var->thread_handle (); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):curr thr handle = %d\n", + thr_handle)); + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):curr scheduled thr handle = %d\n", + curr_scheduled_thr_handle_)); + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):most eligible thr handle = %d \n", + most_eligible_thr_handle)); +#endif + + if (curr_scheduled_thr_handle_ == thr_handle && + most_eligible_thr_handle != thr_handle) + { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):curr sched thr handle = thr_handle & " + "most eligible thr handle != curr thr handle. " + "about to do a broadcast on CV to wake up most eligible\n")); +#endif + curr_scheduled_thr_handle_ = most_eligible_thr_handle; + //wake up the most eligible thread + run_cond_.broadcast (); + } + + //if the current thread is not the most eligible, then wait. + //if the current thread is most eligible, but some thread is + //scheduled currently, then wait. + while (most_eligible_thr_handle != thr_handle || + (most_eligible_thr_handle == thr_handle && + curr_scheduled_thr_handle_ != thr_handle && + curr_scheduled_thr_handle_ != 0)) + { + ACE_Time_Value tv (60,0); + tv += ACE_OS::gettimeofday (); + //wait a maximum of 1 min. This is an escape latch against lockups. +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): About to block on cv\n")); +#endif + if (run_cond_.wait (&tv) == -1) + { + ACE_ERROR ((LM_ERROR, + "(%t|%T): run_cond.wait timed out -- Possible Lockup\n")); + } + ready_queue_.most_eligible (item_var); + most_eligible_thr_handle = item_var->thread_handle (); + } + curr_scheduled_guid_ = item_var->guid (); + curr_scheduled_thr_handle_ = most_eligible_thr_handle; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): %d is currently running\n", + thr_handle)); +#endif + + if (ACE_OS::thr_setprio (thr_handle, active_prio_, sched_policy_) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio failed"))); + } + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i exit\n")); +#endif + + return 0; +} + +template <class DSRT_Scheduler_Traits> +int DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +update_schedule_i (Guid_t guid, const DSRT_QoSDescriptor& qos) +{ + return this->schedule_i (guid, qos); +} + +template <class DSRT_Scheduler_Traits> +int DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +update_schedule_i (Guid_t guid, Block_Flag_t flag) +{ + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, synch_lock_, -1); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t): update schedule for block entered\n")); +#endif + + DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits> dispatch_item; + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + + int found = this->ready_queue_.find (guid, dispatch_item); + +#ifdef KOKYU_DSRT_LOGGING + if (found == 0) + ACE_DEBUG ((LM_DEBUG, "(%t|%T): %d found in ready queue\n", thr_handle)); + else + ACE_DEBUG ((LM_DEBUG, "(%t|%T): %d not found in ready queue\n", + thr_handle)); +#endif + + if (found == 0 && flag == BLOCK) + { + thr_handle = dispatch_item->thread_handle (); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): update schedule: %d found\n", thr_handle)); +#endif + + if (ACE_OS::thr_setprio (thr_handle, blocked_prio_, sched_policy_) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio failed"))); + } + + int rc = this->cancel_schedule (guid); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t): update schedule for block done\n")); +#endif + + return rc; + } + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t): update schedule for block done\n")); +#endif + + return -1; +} + +template <class DSRT_Scheduler_Traits> int +DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +cancel_schedule_i (Guid_t guid) +{ + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, synch_lock_, -1); + + ACE_hthread_t thr_handle; + ACE_Thread::self (thr_handle); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): about to remove guid\n")); +#endif + + ready_queue_.remove (guid); + +#ifdef KOKYU_DSRT_LOGGING + ready_queue_.dump (); +#endif + + if (curr_scheduled_thr_handle_ == thr_handle) + { + curr_scheduled_guid_ = 0; + curr_scheduled_thr_handle_ = 0; + } + + ACE_GUARD_RETURN (cond_lock_t, + mon, run_cond_lock_, 0); + run_cond_.broadcast (); + return 0; +} + +template <class DSRT_Scheduler_Traits> int +DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +shutdown_i () +{ + shutdown_flagged_ = 1; + return 0; +} + +} + +#endif /* DSRT_CV_DISPATCHER_IMPL_T_CPP */ diff --git a/Kokyu/DSRT_CV_Dispatcher_Impl_T.h b/Kokyu/DSRT_CV_Dispatcher_Impl_T.h new file mode 100644 index 00000000000..0cf7045d247 --- /dev/null +++ b/Kokyu/DSRT_CV_Dispatcher_Impl_T.h @@ -0,0 +1,86 @@ +/* -*- C++ -*- */ +/** + * @file DSRT_CV_Dispatcher_Impl_T.h + * + * $Id$ + * + * @author Venkita Subramonian (venkita@cs.wustl.edu) + * + */ + +#ifndef DSRT_CV_DISPATCHER_IMPL_T_H +#define DSRT_CV_DISPATCHER_IMPL_T_H +#include "ace/pre.h" +#include "ace/Task.h" +#include "ace/Copy_Disabled.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "Kokyu_dsrt.h" +#include "DSRT_Sched_Queue_T.h" +#include "DSRT_Dispatcher_Impl_T.h" + +namespace Kokyu +{ + template<class DSRT_Scheduler_Traits> + class DSRT_CV_Dispatcher_Impl : + public DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits>, + public ACE_Copy_Disabled + { + public: + typedef typename + DSRT_Scheduler_Traits::Guid_t Guid_t; + + typedef typename + DSRT_Scheduler_Traits::QoSDescriptor_t DSRT_QoSDescriptor; + + DSRT_CV_Dispatcher_Impl (ACE_Sched_Params::Policy sched_policy, + int sched_scope); + + int init_i (const DSRT_ConfigInfo&); + + /// Schedule a thread dynamically based on the qos info supplied. + int schedule_i (Guid_t, const DSRT_QoSDescriptor&); + + /// Update the schedule for a thread. This could alter the current + /// schedule. + int update_schedule_i (Guid_t, const DSRT_QoSDescriptor&); + + /// Inform the scheduler that the caller thread is about to + /// block. This could alter the current schedule. + int update_schedule_i (Guid_t, Block_Flag_t); + + /// Cancel the schedule for a thread. This could alter the current + /// schedule. + int cancel_schedule_i (Guid_t); + + /// Shut down the dispatcher. The dispatcher will stop processing + /// requests. + int shutdown_i (); + + private: + typedef ACE_SYNCH_MUTEX cond_lock_t; + typedef ACE_SYNCH_CONDITION cond_t; + + cond_lock_t run_cond_lock_; + cond_t run_cond_; + }; + +} + +#if !defined (__ACE_INLINE__) +//#include "DSRT_CV_Dispatcher_Impl_T.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "DSRT_CV_Dispatcher_Impl_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("DSRT_CV_Dispatcher_Impl_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include "ace/post.h" +#endif /* DSRT_DIRECT_DISPATCHER_IMPL_T_H */ diff --git a/Kokyu/DSRT_Direct_Dispatcher_Impl_T.cpp b/Kokyu/DSRT_Direct_Dispatcher_Impl_T.cpp index 56d3331280f..0087f9d3952 100644 --- a/Kokyu/DSRT_Direct_Dispatcher_Impl_T.cpp +++ b/Kokyu/DSRT_Direct_Dispatcher_Impl_T.cpp @@ -40,40 +40,21 @@ operator ()(const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item1, */ template <class DSRT_Scheduler_Traits> DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>:: -DSRT_Direct_Dispatcher_Impl () - :min_prio_ (ACE_Sched_Params::priority_min - (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD)), - max_prio_ (ACE_Sched_Params::priority_max - (ACE_SCHED_FIFO, - ACE_SCOPE_THREAD)), - executive_prio_ (max_prio_), - blocked_prio_ (ACE_Sched_Params::previous_priority - (ACE_SCHED_FIFO, - max_prio_, - ACE_SCOPE_THREAD)), - inactive_prio_ (min_prio_), - active_prio_ (ACE_Sched_Params::next_priority - (ACE_SCHED_FIFO, - min_prio_)), - curr_scheduled_thr_handle_ (0), +DSRT_Direct_Dispatcher_Impl (ACE_Sched_Params::Policy sched_policy, + int sched_scope) + :DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits>(sched_policy, sched_scope), sched_queue_modified_ (0), - sched_queue_modified_cond_ (sched_queue_modified_cond_lock_), - shutdown_flagged_ (0) + sched_queue_modified_cond_ (sched_queue_modified_cond_lock_) { - long flags = - THR_NEW_LWP | - THR_JOINABLE | - THR_BOUND | - THR_SCHED_FIFO; - //Run scheduler thread at highest priority - if (this->activate (flags, 1, 0, executive_prio_) == -1) + if (this->activate (rt_thr_flags_, 1, 0, executive_prio_) == -1) { - flags = THR_NEW_LWP | THR_JOINABLE | THR_BOUND; - if (this->activate (flags) == -1) + ACE_ERROR ((LM_ERROR, + "(%t|%T) cannot activate scheduler thread in RT mode." + "Trying in non RT mode\n")); + if (this->activate (non_rt_thr_flags_) == -1) ACE_ERROR ((LM_ERROR, - "EC (%P|%t) cannot activate scheduler thread\n")); + "(%t|%T) cannot activate scheduler thread\n")); } } @@ -87,10 +68,11 @@ init_i (const DSRT_ConfigInfo&) template <class DSRT_Scheduler_Traits> int DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>::svc (void) { - int prio; ACE_hthread_t scheduler_thr_handle; ACE_Thread::self (scheduler_thr_handle); +#ifdef KOKYU_DSRT_LOGGING + int prio; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("max prio=%d\n") ACE_TEXT ("min prio=%d\n") @@ -101,7 +83,7 @@ DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>::svc (void) active_prio_, inactive_prio_)); - if (ACE_Thread::getprio (scheduler_thr_handle, prio) == -1) + if (ACE_OS::thr_getprio (scheduler_thr_handle, prio) == -1) { if (errno == ENOTSUP) { @@ -118,6 +100,7 @@ DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>::svc (void) } ACE_DEBUG ((LM_DEBUG, "(%t): Scheduler thread prio is %d\n", prio)); +#endif /*DSRT_LOGGING*/ while(1) { @@ -129,38 +112,73 @@ DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>::svc (void) while (!sched_queue_modified_) { +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): sched thread about to wait on cv\n")); +#endif sched_queue_modified_cond_.wait (); } + +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): sched thread done waiting on cv\n")); +#endif sched_queue_modified_ = 0; + ACE_Guard<ACE_SYNCH_RECURSIVE_MUTEX> synch_lock_mon(synch_lock_); if (ready_queue_.current_size () <= 0) continue; +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T):Sched Queue contents===>\n")); ready_queue_.dump (); +#endif DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits> item_var; ready_queue_.most_eligible (item_var); - ACE_hthread_t most_eligible_thread = item_var->thread_handle (); - /* - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%t): most eligible thread guid = %d\n"), - item_var->guid ())); - */ - if (curr_scheduled_thr_handle_ != most_eligible_thread) + ACE_hthread_t most_eligible_thr_handle = item_var->thread_handle (); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):curr scheduled thr handle = %d\n", + curr_scheduled_thr_handle_)); + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):most eligible thr handle = %d \n", + most_eligible_thr_handle)); +#endif + + if (curr_scheduled_thr_handle_ != most_eligible_thr_handle) { - ACE_OS::thr_setprio (curr_scheduled_thr_handle_, - inactive_prio_); - ACE_OS::thr_setprio (most_eligible_thread, active_prio_); - curr_scheduled_thr_handle_ = most_eligible_thread; + if (curr_scheduled_thr_handle_ != 0) + { + if (ACE_OS::thr_setprio (curr_scheduled_thr_handle_, + inactive_prio_, sched_policy_) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio on curr_scheduled_thr_handle_ failed."))); + ACE_DEBUG ((LM_DEBUG, "thr_handle = %d, prio = %d\n", + curr_scheduled_thr_handle_, inactive_prio_)); + } + } + + if (ACE_OS::thr_setprio (most_eligible_thr_handle, + active_prio_, sched_policy_) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio on most_eligible_thr_handle failed"))); + } + + curr_scheduled_thr_handle_ = most_eligible_thr_handle; curr_scheduled_guid_ = item_var->guid (); } } +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): sched thread exiting\n")); +#endif + return 0; } @@ -168,28 +186,62 @@ template <class DSRT_Scheduler_Traits> int DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>:: schedule_i (Guid_t id, const DSRT_QoSDescriptor& qos) { - //@@ Perhaps the lock could be moved further down just before - //setting the condition variable? - ACE_GUARD_RETURN (cond_lock_t, - mon, sched_queue_modified_cond_lock_, 0); - if (ready_queue_.insert (id, qos) == -1) - return -1; + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, synch_lock_, -1); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i enter\n")); +#endif + + DSRT_Dispatch_Item<DSRT_Scheduler_Traits>* item; ACE_hthread_t thr_handle; ACE_Thread::self (thr_handle); - if (ACE_OS::thr_setprio (thr_handle, inactive_prio_) == -1) + ACE_NEW_RETURN (item, + DSRT_Dispatch_Item<DSRT_Scheduler_Traits> (id, qos), + -1); + item->thread_handle (thr_handle); + + if (ready_queue_.insert (item) == -1) + return -1; + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i after ready_q.insert\n")); +#endif + + if (ACE_OS::thr_setprio (thr_handle, blocked_prio_, sched_policy_) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("thr_setprio failed")), - -1); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio failed"))); } - ready_queue_.dump (); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i after thr_setprio\n")); +#endif + + //ready_queue_.dump (); + + //@@ Perhaps the lock could be moved further down just before + //setting the condition variable? + ACE_GUARD_RETURN (cond_lock_t, + mon, sched_queue_modified_cond_lock_, 0); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i after acquiring cond lock\n")); +#endif sched_queue_modified_ = 1; sched_queue_modified_cond_.signal (); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):schedule_i exit\n")); +#endif + return 0; } @@ -204,32 +256,49 @@ template <class DSRT_Scheduler_Traits> int DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>:: update_schedule_i (Guid_t guid, Block_Flag_t flag) { + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, synch_lock_, -1); + +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): update schedule for block entered\n")); +#endif + DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits> dispatch_item; ACE_hthread_t thr_handle; //@@ Perhaps the lock could be got rid of. It looks like the state //of this object is not getting modified here. It makes calls to //other methods, which already are thread-safe. - ACE_Guard<cond_lock_t> mon(sched_queue_modified_cond_lock_); + //ACE_Guard<cond_lock_t> mon(sched_queue_modified_cond_lock_); int found = this->ready_queue_.find (guid, dispatch_item); if (found == 0 && flag == BLOCK) { thr_handle = dispatch_item->thread_handle (); - ACE_OS::thr_setprio (thr_handle, blocked_prio_); + if (ACE_OS::thr_setprio (thr_handle, blocked_prio_, sched_policy_) == -1) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("thr_setprio failed"))); + } //monitor released because cancel_schedule would acquire the //lock. Using recursive mutex creates lock up. // //@@ Need to investigate this further. Also we can consider //using the Thread-Safe interface pattern. - mon.release (); + //mon.release (); int rc = this->cancel_schedule (guid); + +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): update schedule for block done\n")); +#endif + return rc; } +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): update schedule for block done\n")); +#endif + return -1; } @@ -237,13 +306,17 @@ template <class DSRT_Scheduler_Traits> int DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>:: cancel_schedule_i (Guid_t guid) { - //@@ Perhaps the lock could be moved further down? - ACE_GUARD_RETURN (cond_lock_t, - mon, sched_queue_modified_cond_lock_, 0); - ready_queue_.dump (); + ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard, synch_lock_, -1); + +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "(%t): about to remove guid\n")); +#endif + ready_queue_.remove (guid); + +#ifdef KOKYU_DSRT_LOGGING ready_queue_.dump (); +#endif if (curr_scheduled_guid_ == guid) { @@ -251,6 +324,8 @@ cancel_schedule_i (Guid_t guid) curr_scheduled_thr_handle_ = 0; } + ACE_GUARD_RETURN (cond_lock_t, + mon, sched_queue_modified_cond_lock_, 0); sched_queue_modified_ = 1; sched_queue_modified_cond_.signal (); return 0; @@ -260,8 +335,9 @@ template <class DSRT_Scheduler_Traits> int DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>:: shutdown_i () { - ACE_Guard<cond_lock_t> mon(sched_queue_modified_cond_lock_); shutdown_flagged_ = 1; + + ACE_Guard<cond_lock_t> mon(sched_queue_modified_cond_lock_); sched_queue_modified_ = 1; sched_queue_modified_cond_.signal (); // We have to wait until the scheduler executive thread shuts diff --git a/Kokyu/DSRT_Direct_Dispatcher_Impl_T.h b/Kokyu/DSRT_Direct_Dispatcher_Impl_T.h index 404e278a252..1e5dddfaecd 100644 --- a/Kokyu/DSRT_Direct_Dispatcher_Impl_T.h +++ b/Kokyu/DSRT_Direct_Dispatcher_Impl_T.h @@ -25,73 +25,6 @@ namespace Kokyu { - /** - * @class Comparator_Adapter_Generator - * - * @brief Generates function object adapter that adapts the - * QoSComparator function object to compare between two schedulable - * items instead of QoSDescriptors. - * - * The QoSComparator function object that gets passed through the - * <code> DSRT_Scheduler_Traits </code> takes two qos values and - * determines the more eligible one. Since the INT_ID (key) for - * RB_Tree needs to be of type <code> DSRT_Dispatch_Item_var - * </code>, the QoSComparator needs to be adapted using an adapter - * to compare two schedulable items. This adapter compares the two - * using their qos values. Ties are resolved by giving preference to - * items which arrived earlier. Note that this class serves the - * purpose of a generator class, since it generates the adapter - * class for a given qos comparator function object. - */ - - template <class DSRT_Scheduler_Traits> - class Comparator_Adapter_Generator - { - public: - typedef typename - DSRT_Scheduler_Traits::QoSComparator_t QoSComparator_t; - - /** - * @class More_Eligible - * - * @brief Actual function object that gets generated. - */ - class MoreEligible - { - public: - /** - * Function call operator to do comparison between two - * schedulable items. Returns 1 if item1 is more eligible than - * item2, otherwise 0. - */ - int operator () - (const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item1, - const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item2) - { - int rc = qos_comparator_ (item1->qos (), item2->qos ()); - - //more eligible - if (rc == 1) - return 1; - - //if equally eligible, then resolve tie with the creation time of - //the item - if (rc == 0 && item1->insertion_time () < item2->insertion_time ()) - return 1; - - return 0; - } - - private: - QoSComparator_t qos_comparator_; - }; - - /** - * Facilitates return of the generated function object adapter. - */ - typedef MoreEligible RET; - }; - template<class DSRT_Scheduler_Traits> class DSRT_Direct_Dispatcher_Impl : public ACE_Task_Base, @@ -105,7 +38,8 @@ namespace Kokyu typedef typename DSRT_Scheduler_Traits::QoSDescriptor_t DSRT_QoSDescriptor; - DSRT_Direct_Dispatcher_Impl (); + DSRT_Direct_Dispatcher_Impl (ACE_Sched_Params::Policy sched_policy, + int sched_scope); int init_i (const DSRT_ConfigInfo&); @@ -129,33 +63,12 @@ namespace Kokyu int shutdown_i (); private: - - /// Generate the QoSComparator adapter. - typedef typename - Comparator_Adapter_Generator<DSRT_Scheduler_Traits>::RET - Queue_Item_Comparator_t; - - typedef Sched_Ready_Queue<DSRT_Scheduler_Traits, - Queue_Item_Comparator_t, - ACE_SYNCH_NULL_MUTEX> - DSRT_Sched_Queue_t; - typedef ACE_SYNCH_MUTEX cond_lock_t; typedef ACE_SYNCH_CONDITION cond_t; - Priority_t min_prio_; - Priority_t max_prio_; - Priority_t executive_prio_; - Priority_t blocked_prio_; - Priority_t inactive_prio_; - Priority_t active_prio_; - ACE_hthread_t curr_scheduled_thr_handle_; - Guid_t curr_scheduled_guid_; - DSRT_Sched_Queue_t ready_queue_; u_int sched_queue_modified_; cond_lock_t sched_queue_modified_cond_lock_; cond_t sched_queue_modified_cond_; - int shutdown_flagged_; private: int svc (void); diff --git a/Kokyu/DSRT_Dispatch_Item_T.h b/Kokyu/DSRT_Dispatch_Item_T.h index 719a754bb67..5271dfd2abf 100644 --- a/Kokyu/DSRT_Dispatch_Item_T.h +++ b/Kokyu/DSRT_Dispatch_Item_T.h @@ -42,7 +42,7 @@ namespace Kokyu Guid_t guid_; DSRT_QoSDescriptor qos_; ACE_Time_Value insertion_time_; - + public: DSRT_Dispatch_Item (Guid_t guid, const DSRT_QoSDescriptor&); diff --git a/Kokyu/DSRT_Dispatcher_Impl_T.cpp b/Kokyu/DSRT_Dispatcher_Impl_T.cpp index 2bfb610b412..4e7cace0a1e 100644 --- a/Kokyu/DSRT_Dispatcher_Impl_T.cpp +++ b/Kokyu/DSRT_Dispatcher_Impl_T.cpp @@ -14,6 +14,37 @@ ACE_RCSID(Kokyu, DSRT_Dispatcher_Impl, "$Id$") namespace Kokyu { +template <class DSRT_Scheduler_Traits> +DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits>:: +DSRT_Dispatcher_Impl (ACE_Sched_Params::Policy sched_policy, + int sched_scope) + : sched_policy_ (sched_policy), + sched_scope_ (sched_scope), + min_prio_ (ACE_Sched_Params::priority_min + (sched_policy_, + sched_scope)), + max_prio_ (ACE_Sched_Params::priority_max + (sched_policy_, + sched_scope)), + executive_prio_ (max_prio_), + blocked_prio_ (ACE_Sched_Params::previous_priority + (sched_policy_, + max_prio_, + sched_scope)), + inactive_prio_ (min_prio_), + active_prio_ (ACE_Sched_Params::next_priority + (sched_policy_, + min_prio_)), + shutdown_flagged_ (0), + non_rt_thr_flags_ (THR_NEW_LWP | THR_JOINABLE | THR_BOUND), + curr_scheduled_thr_handle_ (0) +{ + if (sched_policy_ == ACE_SCHED_FIFO) + rt_thr_flags_ = non_rt_thr_flags_ | THR_SCHED_FIFO; + else if (sched_policy_ == ACE_SCHED_RR) + rt_thr_flags_ = non_rt_thr_flags_ | THR_SCHED_RR; +} + //virtual - so don't inline template <class DSRT_Scheduler_Traits> DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits>::~DSRT_Dispatcher_Impl () diff --git a/Kokyu/DSRT_Dispatcher_Impl_T.h b/Kokyu/DSRT_Dispatcher_Impl_T.h index fd847ca0faa..232d6069f10 100644 --- a/Kokyu/DSRT_Dispatcher_Impl_T.h +++ b/Kokyu/DSRT_Dispatcher_Impl_T.h @@ -20,6 +20,79 @@ namespace Kokyu { /** + * @class Comparator_Adapter_Generator + * + * @brief Generates function object adapter that adapts the + * QoSComparator function object to compare between two schedulable + * items instead of QoSDescriptors. + * + * The QoSComparator function object that gets passed through the + * <code> DSRT_Scheduler_Traits </code> takes two qos values and + * determines the more eligible one. Since the INT_ID (key) for + * RB_Tree needs to be of type <code> DSRT_Dispatch_Item_var + * </code>, the QoSComparator needs to be adapted using an adapter + * to compare two schedulable items. This adapter compares the two + * using their qos values. Ties are resolved by giving preference to + * items which arrived earlier. Note that this class serves the + * purpose of a generator class, since it generates the adapter + * class for a given qos comparator function object. + */ + + template <class DSRT_Scheduler_Traits> + class Comparator_Adapter_Generator + { + public: + typedef typename + DSRT_Scheduler_Traits::QoSComparator_t QoSComparator_t; + + /** + * @class More_Eligible + * + * @brief Actual function object that gets generated. + */ + class MoreEligible + { + public: + /** + * Function call operator to do comparison between two + * schedulable items. Returns 1 if item1 is more eligible than + * item2, otherwise 0. + */ + int operator () + (const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item1, + const DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits>& item2) + { + int rc = qos_comparator_ (item1->qos (), item2->qos ()); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T): MoreEligible:: qos_comparator returned %d\n", + rc)); +#endif + + //more eligible + if (rc == 1) + return rc; + + //if equally eligible, then resolve tie with the creation time of + //the item + if (rc == 0 && item1->insertion_time () < item2->insertion_time ()) + return 1; + + return 0; + } + + private: + QoSComparator_t qos_comparator_; + }; + + /** + * Facilitates return of the generated function object adapter. + */ + typedef MoreEligible RET; + }; + + /** * @class DSRT_Dispatcher * * @brief Base class for DSRT dispatcher implementations @@ -35,6 +108,9 @@ namespace Kokyu typedef typename DSRT_Scheduler_Traits::Guid_t Guid_t; typedef typename DSRT_Scheduler_Traits::QoSDescriptor_t DSRT_QoSDescriptor; + DSRT_Dispatcher_Impl (ACE_Sched_Params::Policy sched_policy, + int sched_scope); + /// Configure the DSRT dispatcher. int init (const DSRT_ConfigInfo&); @@ -76,6 +152,36 @@ namespace Kokyu virtual int cancel_schedule_i (Guid_t guid)=0; virtual int shutdown_i ()=0; + protected: + /// Generate the QoSComparator adapter. + typedef typename + Comparator_Adapter_Generator<DSRT_Scheduler_Traits>::RET + Queue_Item_Comparator_t; + + typedef Sched_Ready_Queue<DSRT_Scheduler_Traits, + Queue_Item_Comparator_t, + ACE_SYNCH_NULL_MUTEX> + DSRT_Sched_Queue_t; + + ACE_Sched_Params::Policy sched_policy_; + int sched_scope_; + + Priority_t min_prio_; + Priority_t max_prio_; + Priority_t executive_prio_; + Priority_t blocked_prio_; + Priority_t inactive_prio_; + Priority_t active_prio_; + + DSRT_Sched_Queue_t ready_queue_; + int shutdown_flagged_; + long non_rt_thr_flags_; + long rt_thr_flags_; + + ACE_SYNCH_RECURSIVE_MUTEX synch_lock_; + + ACE_hthread_t curr_scheduled_thr_handle_; + Guid_t curr_scheduled_guid_; }; } //end of namespace diff --git a/Kokyu/DSRT_Sched_Queue_T.cpp b/Kokyu/DSRT_Sched_Queue_T.cpp index 65a24b33a15..8d6e95dc8d9 100644 --- a/Kokyu/DSRT_Sched_Queue_T.cpp +++ b/Kokyu/DSRT_Sched_Queue_T.cpp @@ -102,56 +102,83 @@ template <class DSRT_Scheduler_Traits, int Sched_Ready_Queue<DSRT_Scheduler_Traits, More_Eligible_Comparator, ACE_LOCK>:: -insert(Guid_t guid, const DSRT_QoSDescriptor_t& qos) +insert (DSRT_Dispatch_Item<DSRT_Scheduler_Traits>* item) { - DSRT_Dispatch_Item<DSRT_Scheduler_Traits>* item; - ACE_hthread_t thr_handle; - ACE_Thread::self (thr_handle); - - ACE_NEW_RETURN (item, - DSRT_Dispatch_Item<DSRT_Scheduler_Traits> (guid, qos), - -1); - item->thread_handle (thr_handle); item->insertion_time (ACE_OS::gettimeofday ()); DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits> item_var(item); ACE_GUARD_RETURN (ACE_LOCK, mon, lock_, -1); RB_Tree_Dispatch_Item_Node* rb_tree_node; - if (dispatch_items_hash_map_.find(guid, rb_tree_node) == -1) + Guid_t guid = item->guid (); + +#ifdef KOKYU_DSRT_LOGGING + ACE_hthread_t thr_handle = item->thread_handle (); + + ACE_DEBUG ((LM_DEBUG, + "(%t|%T) about to insert %d in sched queue\n", + thr_handle)); +#endif + + if (dispatch_items_hash_map_.find (guid, rb_tree_node) == -1) { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T) %d not found in hashmap\n", thr_handle)); +#endif if (dispatch_items_prio_queue_.bind (item_var, item_var, rb_tree_node) == 0) { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): item bound in rbtree\n")); +#endif if (dispatch_items_hash_map_.bind (guid, rb_tree_node) == 0) { - ACE_DEBUG ((LM_DEBUG, "(%t) insert item done\n")); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, "(%t|%T): item bound in hashmap\n")); ACE_DEBUG ((LM_DEBUG, "<===Hash Table contents Begin===>\n")); dispatch_items_hash_map_.dump (); ACE_DEBUG ((LM_DEBUG, "<===Hash Table contents End=====>\n")); +#endif return 0; } } } else { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T) %d found in hashmap\n", thr_handle)); +#endif dispatch_items_hash_map_.unbind (guid); dispatch_items_prio_queue_.unbind (rb_tree_node); + +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T) %d removed from hashmap and rbtree\n", thr_handle)); +#endif if (dispatch_items_prio_queue_.bind (item_var, item_var, rb_tree_node) == 0) { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T) %d bound to rbtree\n", thr_handle)); +#endif if (dispatch_items_hash_map_.bind (guid, rb_tree_node) == 0) { - ACE_DEBUG ((LM_DEBUG, "(%t) insert item done\n")); +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T) %d bound to hashmap\n", thr_handle)); ACE_DEBUG ((LM_DEBUG, "<===Hash Table contents Begin===>\n")); dispatch_items_hash_map_.dump (); ACE_DEBUG ((LM_DEBUG, "<===Hash Table contents End===>\n")); +#endif return 0; } } @@ -164,7 +191,7 @@ template <class DSRT_Scheduler_Traits, class More_Eligible_Comparator, class ACE_LOCK> int Sched_Ready_Queue<DSRT_Scheduler_Traits, More_Eligible_Comparator, ACE_LOCK>:: -remove(Guid_t guid) +remove (Guid_t guid) { ACE_GUARD_RETURN (ACE_LOCK, mon, lock_, -1); RB_Tree_Dispatch_Item_Node* rb_tree_node; @@ -173,11 +200,14 @@ remove(Guid_t guid) { dispatch_items_hash_map_.unbind (guid); dispatch_items_prio_queue_.unbind (rb_tree_node); +#ifdef KOKYU_DSRT_LOGGING ACE_DEBUG ((LM_DEBUG, "<===Hash Table contents Begin===>\n")); dispatch_items_hash_map_.dump (); ACE_DEBUG ((LM_DEBUG, "<===Hash Table contents End===>\n")); +#endif + return 0; } @@ -190,31 +220,34 @@ template <class DSRT_Scheduler_Traits, void Sched_Ready_Queue<DSRT_Scheduler_Traits, More_Eligible_Comparator, ACE_LOCK>:: -dump() +dump () { ACE_GUARD (ACE_LOCK, mon, lock_); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):##########################\n")); if (dispatch_items_prio_queue_.current_size ()) { PRIO_QUEUE_ITERATOR end_iter = dispatch_items_prio_queue_.end (); - PRIO_QUEUE_ITERATOR start; + PRIO_QUEUE_ITERATOR iter; - start = dispatch_items_prio_queue_.begin (); - while( start != end_iter ) + iter = dispatch_items_prio_queue_.begin (); + while( iter != end_iter ) { - PRIO_QUEUE_ENTRY &ent = (*start); + PRIO_QUEUE_ENTRY &ent = (*iter); DSRT_Dispatch_Item_var<DSRT_Scheduler_Traits> item_var = ent.item (); - /* + /* int guid; ACE_OS::memcpy (&guid, - item_var->guid ()->get_buffer (), - item_var->guid ()->length ()); + item_var->guid ().get_buffer (), + item_var->guid ().length ()); - ACE_DEBUG ((LM_DEBUG, "guid %d\n", guid)); + ACE_DEBUG ((LM_DEBUG, "(%t|%T):guid %d, thr_handle = %d\n", + guid, item_var->thread_handle ())); */ - ++start; + ++iter; } } + ACE_DEBUG ((LM_DEBUG, "(%t|%T):##########################\n")); } } diff --git a/Kokyu/DSRT_Sched_Queue_T.h b/Kokyu/DSRT_Sched_Queue_T.h index 0c03e975609..166009d7fb3 100644 --- a/Kokyu/DSRT_Sched_Queue_T.h +++ b/Kokyu/DSRT_Sched_Queue_T.h @@ -91,13 +91,11 @@ namespace Kokyu * one inserted. A deletion and insertion has to happen instead of * update since the rebalancing of the RB_Tree should take place. * - * @param guid Guid of item. - * - * @param qos QoS associated with item. + * @param item <code> DSRT_Dispatch_Item </code> object containing guid and qos. * * @return -1 if insertion failed and 0 otherwise. */ - int insert(Guid_t guid, const DSRT_QoSDescriptor_t& qos); + int insert(DSRT_Dispatch_Item<DSRT_Scheduler_Traits>* item); /** * Remove an item from the priority queue. diff --git a/Kokyu/Kokyu_dsrt.cpp b/Kokyu/Kokyu_dsrt.cpp index 569ada08cfa..a6f18760065 100644 --- a/Kokyu/Kokyu_dsrt.cpp +++ b/Kokyu/Kokyu_dsrt.cpp @@ -4,6 +4,7 @@ #include "ace/Dynamic_Service.h" #include "DSRT_Direct_Dispatcher_Impl_T.h" +#include "DSRT_CV_Dispatcher_Impl_T.h" #if ! defined (__ACE_INLINE__) #include "Kokyu_dsrt.i" @@ -74,7 +75,26 @@ create_DSRT_dispatcher (const DSRT_ConfigInfo& config_info) //tmp = // ACE_Dynamic_Service<DSRT_Dispatcher_Impl>::instance ("DSRT_Dispatcher_Impl"); - ACE_NEW_RETURN (tmp, DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits>, nil_ptr); + switch (config_info.impl_type_) + { + case DSRT_OS_BASED: + ACE_NEW_RETURN (tmp, + DSRT_Direct_Dispatcher_Impl<DSRT_Scheduler_Traits> ( + config_info.sched_policy_, + config_info.sched_scope_), + nil_ptr); + break; + + case DSRT_CV_BASED: + default: + ACE_NEW_RETURN (tmp, + DSRT_CV_Dispatcher_Impl<DSRT_Scheduler_Traits>( + config_info.sched_policy_, + config_info.sched_scope_), + nil_ptr); + break; + } + ACE_ASSERT (tmp != 0); ACE_NEW_RETURN (disp, DSRT_Dispatcher<DSRT_Scheduler_Traits>, nil_ptr); DSRT_Dispatcher_Auto_Ptr disp_auto_ptr(disp); @@ -83,17 +103,21 @@ create_DSRT_dispatcher (const DSRT_ConfigInfo& config_info) return disp_auto_ptr; } -template <class QoSDescriptor> -int MUF_Comparator<QoSDescriptor>:: -operator ()(const QoSDescriptor& qos1, - const QoSDescriptor& qos2) +template <class QoSDescriptor_t> +int MUF_Comparator<QoSDescriptor_t>:: +operator ()(const QoSDescriptor_t& qos1, + const QoSDescriptor_t& qos2) { if (qos1.criticality_ > qos2.criticality_) { return 1; } + else if (qos2.criticality_ > qos1.criticality_) + { + return -1; + } - typename QoSDescriptor::Now now_functor; + typename QoSDescriptor_t::Now now_functor; Time_t now = now_functor (); Time_t exec_time1 = qos1.exec_time_; @@ -122,6 +146,12 @@ int MIF_Comparator<QoSDescriptor>:: operator ()(const QoSDescriptor& qos1, const QoSDescriptor& qos2) { +#ifdef KOKYU_DSRT_LOGGING + ACE_DEBUG ((LM_DEBUG, + "(%t|%T):qos1.importance = %d, qos2.importance = %d\n", + qos1.importance_, qos2.importance_)); +#endif + if (qos1.importance_ > qos2.importance_) { return 1; diff --git a/Kokyu/tests/DSRT_MIF/MIF.cpp b/Kokyu/tests/DSRT_MIF/MIF.cpp index 4e1b14b9665..0a90aef28d1 100644 --- a/Kokyu/tests/DSRT_MIF/MIF.cpp +++ b/Kokyu/tests/DSRT_MIF/MIF.cpp @@ -59,9 +59,10 @@ public: ACE_Thread::self (thr_handle); int prio; + ACE_DEBUG ((LM_DEBUG, "(%t|%T): task activated\n")); ACE_ASSERT (dispatcher_ != 0); - prio = dispatcher_->schedule (guid_, qos_); barrier_.wait (); + prio = dispatcher_->schedule (guid_, qos_); if (ACE_Thread::getprio (thr_handle, prio) == -1) { @@ -72,10 +73,9 @@ public: )); return 0; } - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("%p\n"), - ACE_TEXT ("getprio failed")), - -1); + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("getprio failed"))); } ACE_DEBUG ((LM_DEBUG, "(%t) Thread prio=%d, guid=%d, qos_.importance=%d \n", prio, guid_, qos_.importance_)); @@ -162,6 +162,7 @@ template class Kokyu::DSRT_Dispatcher_Factory<mif_scheduler_traits>; template class Kokyu::DSRT_Dispatcher<mif_scheduler_traits>; template class Kokyu::DSRT_Dispatcher_Impl<mif_scheduler_traits>; template class Kokyu::DSRT_Direct_Dispatcher_Impl<mif_scheduler_traits>; +template class Kokyu::DSRT_CV_Dispatcher_Impl<mif_scheduler_traits>; template class ACE_Lock_Adapter<ACE_Thread_Mutex>; template class Kokyu::DSRT_Dispatch_Item_var<mif_scheduler_traits>; template class Kokyu::Comparator_Adapter_Generator<mif_scheduler_traits>; @@ -192,6 +193,7 @@ template class ACE_Array_Iterator<Kokyu::ConfigInfo>; #pragma instantiate Kokyu::DSRT_Dispatcher<mif_scheduler_traits> #pragma instantiate Kokyu::DSRT_Dispatcher_Impl<mif_scheduler_traits> #pragma instantiate Kokyu::DSRT_Direct_Dispatcher_Impl<mif_scheduler_traits> +#pragma instantiate Kokyu::DSRT_CV_Dispatcher_Impl<mif_scheduler_traits> #pragma instantiate Kokyu::DSRT_Dispatch_Item_var<mif_scheduler_traits> #pragma instantiate Kokyu::Comparator_Adapter_Generator<mif_scheduler_traits> diff --git a/Kokyu/tests/DSRT_MIF/Makefile b/Kokyu/tests/DSRT_MIF/Makefile index 11f86df03fb..8304cf22d55 100644 --- a/Kokyu/tests/DSRT_MIF/Makefile +++ b/Kokyu/tests/DSRT_MIF/Makefile @@ -28,7 +28,7 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU # Local targets #---------------------------------------------------------------------------- -CPPFLAGS += -I$(ACE_ROOT)/Kokyu +CPPFLAGS += -I$(ACE_ROOT)/Kokyu -DKOKYU_DSRT_LOGGING LDFLAGS += -lKokyu #---------------------------------------------------------------------------- |