diff options
Diffstat (limited to 'src/systemc/tests/systemc/kernel/process_control/throw_it')
-rw-r--r-- | src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log | 5 | ||||
-rw-r--r-- | src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp | 57 |
2 files changed, 62 insertions, 0 deletions
diff --git a/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log new file mode 100644 index 000000000..18c914736 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/golden/test1.log @@ -0,0 +1,5 @@ +SystemC Simulation +0 s: starting victim thread +10 ns: in perpetrator throwing exception in victim +10 ns: in victim thread, caught exception from pepetrator, exiting +10 ns: in perpetrator after throwing exception in victim diff --git a/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp new file mode 100644 index 000000000..1a3ceb192 --- /dev/null +++ b/src/systemc/tests/systemc/kernel/process_control/throw_it/test1/test1.cpp @@ -0,0 +1,57 @@ +//---------------------------------------------------------------------- +// Copyright 2009 Cadence Design Systems, Inc. +// All Rights Reserved Worldwide +//---------------------------------------------------------------------- + +#include <systemc.h> + +class my_exception { +public: + my_exception(const char* s) : s_(s) { } + const char* message() { return s_.c_str(); } +protected: + std::string s_; +}; + +SC_MODULE(top) { +public: + SC_CTOR(top) { + SC_THREAD(victim); + h = sc_get_current_process_handle(); + SC_THREAD(perpetrator); + } + + void victim() { + try { + cerr << sc_time_stamp() << ": starting victim thread" << endl; + ::sc_core::wait(100, SC_NS); + } + catch (my_exception& x) { + cerr << sc_time_stamp() << ": in victim thread, caught exception " + << x.message() << ", exiting" << endl; + return; + } + } + + void perpetrator() { + wait(10, SC_NS); + cerr << sc_time_stamp() + << ": in perpetrator throwing exception in victim " + << endl; + h.throw_it(my_exception("from pepetrator")); + cerr << sc_time_stamp() + << ": in perpetrator after throwing exception in victim " + << endl; + } + +protected: + sc_process_handle h; +}; + +int sc_main (int argc, char *argv[]) +{ + top t("top"); + sc_start(); + return 0; +} + |