diff options
author | venkita <venkita@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-10-12 13:48:46 +0000 |
---|---|---|
committer | venkita <venkita@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-10-12 13:48:46 +0000 |
commit | 367e0c6edf785c7f1bdaf597c8d19d4a00ba727f (patch) | |
tree | b038deebba6fb1644b95603d0e5aa9907383e664 /Kokyu | |
parent | cf585bd4cbba1b7a442f68c70322d3835c1cf19e (diff) | |
download | ATCD-367e0c6edf785c7f1bdaf597c8d19d4a00ba727f.tar.gz |
ChangeLogTag: Sun Oct 12 08:42:32 2003 Venkita Subramonian <venkita@cs.wustl.edu>
Diffstat (limited to 'Kokyu')
-rw-r--r-- | Kokyu/tests/DSRT_MIF/MIF.cpp | 104 | ||||
-rw-r--r-- | Kokyu/tests/DSRT_MIF/Makefile | 3 | ||||
-rw-r--r-- | Kokyu/tests/EDF/README | 24 | ||||
-rw-r--r-- | Kokyu/tests/EDF/test.cpp | 27 | ||||
-rw-r--r-- | Kokyu/tests/FIFO/README | 24 | ||||
-rw-r--r-- | Kokyu/tests/FIFO/test.cpp | 16 |
6 files changed, 138 insertions, 60 deletions
diff --git a/Kokyu/tests/DSRT_MIF/MIF.cpp b/Kokyu/tests/DSRT_MIF/MIF.cpp index 0a90aef28d1..276271d3b62 100644 --- a/Kokyu/tests/DSRT_MIF/MIF.cpp +++ b/Kokyu/tests/DSRT_MIF/MIF.cpp @@ -5,6 +5,8 @@ #include "ace/Sched_Params.h" #include "ace/Atomic_Op.h" #include "ace/Synch.h" +#include "ace/High_Res_Timer.h" + #include "Kokyu_dsrt.h" ACE_Atomic_Op<ACE_SYNCH_MUTEX, long> guid=0; @@ -46,55 +48,81 @@ public: MyTask (ACE_Barrier& barrier, Kokyu::DSRT_Dispatcher<mif_scheduler_traits>* dispatcher, - mif_scheduler_traits::QoSDescriptor_t& qos) + mif_scheduler_traits::QoSDescriptor_t& qos, + int exec_duration) :barrier_ (barrier), dispatcher_ (dispatcher), qos_ (qos), - guid_ (++guid) + guid_ (++guid), + exec_duration_ (exec_duration) {} - int svc (void) - { - ACE_hthread_t thr_handle; - ACE_Thread::self (thr_handle); - int prio; - - ACE_DEBUG ((LM_DEBUG, "(%t|%T): task activated\n")); - ACE_ASSERT (dispatcher_ != 0); - barrier_.wait (); - prio = dispatcher_->schedule (guid_, qos_); - - 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 ((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_)); - dispatcher_->cancel_schedule (this->guid_); - return 0; - } + int svc (void); -private: + private: ACE_Barrier& barrier_; Kokyu::DSRT_Dispatcher<mif_scheduler_traits>* dispatcher_; mif_scheduler_traits::QoSDescriptor_t qos_; mif_scheduler_traits::Guid_t guid_; + int exec_duration_; }; +int MyTask::svc (void) +{ + ACE_hthread_t thr_handle; + 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 (); + + long prime_number = 9619899; + + ACE_High_Res_Timer timer; + ACE_Time_Value elapsed_time; + ACE_Time_Value seconds_tracker(0,0); + + ACE_Time_Value one_second (1,0); + ACE_Time_Value compute_count_down_time (exec_duration_, 0); + ACE_Countdown_Time compute_count_down (&compute_count_down_time); + + timer.start (); + while (compute_count_down_time > ACE_Time_Value::zero) + { + ACE::is_prime (prime_number, + 2, + prime_number / 2); + + compute_count_down.update (); + timer.stop (); + timer.elapsed_time (elapsed_time); + seconds_tracker += elapsed_time; + if (seconds_tracker >= one_second) + { + seconds_tracker.set (0,0); + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%t) Currently running guid=%d") + ACE_TEXT (", qos_.importance=%d \n"), + guid_, qos_.importance_)); + } + timer.reset (); + timer.start (); + } + + dispatcher_->cancel_schedule (this->guid_); + return 0; +} + int main (int,char**) { Kokyu::DSRT_ConfigInfo config_info; // config_info.scheduler_type_ = Kokyu::SCHED_MIF; + config_info.impl_type_ = Kokyu::DSRT_OS_BASED; ACE_Barrier barrier (3); @@ -114,11 +142,11 @@ int main (int,char**) qos1.importance_ = 1; qos2.importance_ = 2; - qos3.importance_ = 1; + qos3.importance_ = 3; - MyTask mytask1 (barrier, disp.get (), qos1); - MyTask mytask2 (barrier, disp.get (), qos2); - MyTask mytask3 (barrier, disp.get (), qos3); + MyTask mytask1 (barrier, disp.get (), qos1, 15); + MyTask mytask2 (barrier, disp.get (), qos2, 6); + MyTask mytask3 (barrier, disp.get (), qos3, 4); long flags = THR_BOUND | THR_SCHED_FIFO; @@ -146,12 +174,8 @@ int main (int,char**) "EC (%P|%t) cannot activate task\n")); } - ACE_OS::sleep (5); - disp->shutdown (); - ACE_OS::sleep (5); - ACE_DEBUG ((LM_DEBUG, "main thread exiting\n")); return 0; diff --git a/Kokyu/tests/DSRT_MIF/Makefile b/Kokyu/tests/DSRT_MIF/Makefile index 8304cf22d55..3a122424056 100644 --- a/Kokyu/tests/DSRT_MIF/Makefile +++ b/Kokyu/tests/DSRT_MIF/Makefile @@ -28,7 +28,8 @@ include $(ACE_ROOT)/include/makeinclude/rules.local.GNU # Local targets #---------------------------------------------------------------------------- -CPPFLAGS += -I$(ACE_ROOT)/Kokyu -DKOKYU_DSRT_LOGGING +#CPPFLAGS += -I$(ACE_ROOT)/Kokyu -DKOKYU_DSRT_LOGGING +CPPFLAGS += -I$(ACE_ROOT)/Kokyu LDFLAGS += -lKokyu #---------------------------------------------------------------------------- diff --git a/Kokyu/tests/EDF/README b/Kokyu/tests/EDF/README new file mode 100644 index 00000000000..4f209605e14 --- /dev/null +++ b/Kokyu/tests/EDF/README @@ -0,0 +1,24 @@ +This example is a very simple example, showing how to use the Kokyu +dispatcher to dispatch command objects in a EDF manner. The test +configures the Kokyu dispatcher with a single EDF lane. Typically this +would be done by an EDF scheduler which assigns priorities to tasks +based on the deadlines for tasks. To ensure that the command objects +enqueued in the dispatcher are dispatched in the correct order, we +enqueue the command objects and *then* activate the dispatcher. Only +when the dispatcher is activated, the thread watching each dispatch +queue starts running. + +To run this example, + +./test -p<fifo|rr|other> + +The following is the expected output + +Deadline of command1 is 1065966081 +Deadline of command2 is 1065966131 +Deadline of command3 is 1065966031 +command 3 executed +command 1 executed +command 2 executed + +Note that the deadlines are absolute deadlines. diff --git a/Kokyu/tests/EDF/test.cpp b/Kokyu/tests/EDF/test.cpp index 8b8882f88e3..7844f4cbf4a 100644 --- a/Kokyu/tests/EDF/test.cpp +++ b/Kokyu/tests/EDF/test.cpp @@ -19,9 +19,14 @@ public: :Kokyu::Dispatch_Command(1),id_(i) { } + int execute(); - int execute() - { +private: + int id_; +}; + +int MyCommand::execute() +{ ACE_hthread_t thr_handle; ACE_Thread::self (thr_handle); int prio; @@ -45,12 +50,7 @@ public: ACE_TEXT (("(%t|prio=%d) | command %d executed\n")), prio, id_)); return 0; - } - -private: - int id_; -}; - +} int main (int argc, char** argv) { @@ -113,12 +113,17 @@ int main (int argc, char** argv) qos3.preemption_priority_ = 1; qos3.deadline_ = deadline3; + ACE_DEBUG ((LM_DEBUG, "Deadline of command1 is %d\n", + qos1.deadline_.sec ())); disp->dispatch (&cmd1, qos1); - printf("inserted 1\n"); + + ACE_DEBUG ((LM_DEBUG, "Deadline of command2 is %d\n", + qos2.deadline_.sec ())); disp->dispatch (&cmd2, qos2); - printf("inserted 2\n"); + + ACE_DEBUG ((LM_DEBUG, "Deadline of command3 is %d\n", + qos3.deadline_.sec ())); disp->dispatch (&cmd3, qos3); - printf("inserted 3\n"); disp->activate (); diff --git a/Kokyu/tests/FIFO/README b/Kokyu/tests/FIFO/README new file mode 100644 index 00000000000..5700e4a5038 --- /dev/null +++ b/Kokyu/tests/FIFO/README @@ -0,0 +1,24 @@ +This example is a very simple example, showing how to use the Kokyu +dispatcher to dispatch command objects in a FIFO manner. The test +configures the Kokyu dispatcher with 3 FIFO lanes, each having a +different priority. Typically this would be done by an RMS scheduler +which assigns priorities to tasks based on the rate of tasks. To +ensure that the command objects enqueued in the dispatcher are +dispatched in the correct order, we enqueue the command objects and +*then* activate the dispatcher. Only when the dispatcher is activated, +the thread watching each dispatch queue starts running. + +To run this example, + +./test -p<fifo|rr|other> + +The following is the expected output + +Priority of command1 is 2 +Priority of command2 is 3 +Priority of command3 is 1 +command 3 executed +command 1 executed +command 2 executed + +Note that a lower number means a higher priority for the task. diff --git a/Kokyu/tests/FIFO/test.cpp b/Kokyu/tests/FIFO/test.cpp index fab7f34698c..c61f14fdcfd 100644 --- a/Kokyu/tests/FIFO/test.cpp +++ b/Kokyu/tests/FIFO/test.cpp @@ -18,9 +18,14 @@ public: :Kokyu::Dispatch_Command(1),id_(i) { } + int execute (); - int execute() - { +private: + int id_; +}; + +int MyCommand::execute() +{ ACE_hthread_t thr_handle; ACE_Thread::self (thr_handle); int prio; @@ -44,12 +49,7 @@ public: ACE_TEXT (("(%t|prio=%d) | command %d executed\n")), prio, id_)); return 0; - } - -private: - int id_; -}; - +} int main (int argc, char** argv) { |