summaryrefslogtreecommitdiff
path: root/Kokyu/tests/DSRT_MIF/MIF.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Kokyu/tests/DSRT_MIF/MIF.cpp')
-rw-r--r--Kokyu/tests/DSRT_MIF/MIF.cpp76
1 files changed, 61 insertions, 15 deletions
diff --git a/Kokyu/tests/DSRT_MIF/MIF.cpp b/Kokyu/tests/DSRT_MIF/MIF.cpp
index 136523c8aaa..620718aa07e 100644
--- a/Kokyu/tests/DSRT_MIF/MIF.cpp
+++ b/Kokyu/tests/DSRT_MIF/MIF.cpp
@@ -2,20 +2,55 @@
#include "ace/Auto_Ptr.h"
-#include "Kokyu.h"
+#include "Kokyu_dsrt.h"
#include "ace/Task.h"
#include "ace/Sched_Params.h"
+#include "ace/Atomic_Op.h"
+
+ACE_Atomic_Op<ACE_Thread_Mutex, long> guid=0;
+
+struct mif_scheduler_traits
+{
+ typedef int Guid_t;
+
+ struct QoSDescriptor_t
+ {
+ typedef long Importance_t;
+
+ long importance_;
+ };
+
+ /*
+ static Time_t now()
+ {
+ ACE_Time_Value now = ACE_OS::gettimeofday ();
+ return now.sec () * 10000000 + now.usec () * 10;
+ }
+ */
+
+ typedef Kokyu::MIF_Comparator<QoSDescriptor_t> QoSComparator_t;
+
+ struct Guid_Hash
+ {
+ u_long operator () (const Guid_t& guid)
+ {
+ return guid;
+ }
+ };
+};
+
class MyTask : public ACE_Task_Base
{
public:
MyTask (ACE_Barrier& barrier,
- Kokyu::DSRT_Dispatcher* dispatcher,
- Kokyu::DSRT_QoSDescriptor& qos)
+ Kokyu::DSRT_Dispatcher<mif_scheduler_traits>* dispatcher,
+ mif_scheduler_traits::QoSDescriptor_t& qos)
:barrier_ (barrier),
dispatcher_ (dispatcher),
- qos_ (qos)
+ qos_ (qos),
+ guid_ (++guid)
{}
int svc (void)
@@ -24,8 +59,8 @@ public:
ACE_Thread::self (thr_handle);
int prio;
- prio = dispatcher_->schedule (0, qos_);
- ACE_Thread::setprio (thr_handle, prio);
+ ACE_ASSERT (dispatcher_ != 0);
+ prio = dispatcher_->schedule (guid_, qos_);
barrier_.wait ();
if (ACE_Thread::getprio (thr_handle, prio) == -1)
@@ -43,15 +78,16 @@ public:
-1);
}
- ACE_DEBUG ((LM_DEBUG, "(%t) Thread prio is %d\n", prio));
+ ACE_DEBUG ((LM_DEBUG, "(%t) Thread prio=%d, guid=%d, qos_.importance=%d \n", prio, guid_, qos_.importance_));
+ dispatcher_->cancel_schedule (this->guid_);
return 0;
}
private:
ACE_Barrier& barrier_;
- Kokyu::DSRT_Dispatcher* dispatcher_;
- Kokyu::DSRT_QoSDescriptor& qos_;
-
+ Kokyu::DSRT_Dispatcher<mif_scheduler_traits>* dispatcher_;
+ mif_scheduler_traits::QoSDescriptor_t qos_;
+ mif_scheduler_traits::Guid_t guid_;
};
int main (int,char**)
@@ -63,18 +99,22 @@ int main (int,char**)
ACE_Barrier barrier (3);
ACE_DEBUG ((LM_DEBUG, "before create_dispatcher\n" ));
- auto_ptr<Kokyu::DSRT_Dispatcher>
- disp (Kokyu::Dispatcher_Factory::create_DSRT_dispatcher (config_info));
+
+ config_info.sched_strategy_ = Kokyu::DSRT_MIF;
+
+ Kokyu::DSRT_Dispatcher_Factory<mif_scheduler_traits>::DSRT_Dispatcher_Auto_Ptr
+ disp (Kokyu::DSRT_Dispatcher_Factory<mif_scheduler_traits>::
+ create_DSRT_dispatcher (config_info));
ACE_DEBUG ((LM_DEBUG, "after create_dispatcher\n" ));
ACE_ASSERT (disp.get () != 0);
- Kokyu::DSRT_QoSDescriptor qos1, qos2, qos3;
+ mif_scheduler_traits::QoSDescriptor_t qos1, qos2, qos3;
qos1.importance_ = 1;
qos2.importance_ = 2;
- qos3.importance_ = 3;
+ qos3.importance_ = 1;
MyTask mytask1 (barrier, disp.get (), qos1);
MyTask mytask2 (barrier, disp.get (), qos2);
@@ -106,7 +146,13 @@ int main (int,char**)
"EC (%P|%t) cannot activate task\n"));
}
- while(1){}
+ ACE_OS::sleep (5);
+
+ disp->shutdown ();
+
+ ACE_OS::sleep (5);
+
+ ACE_DEBUG ((LM_DEBUG, "main thread exiting\n"));
return 0;
}