SystemC 2.3:reset and kill
SystemC 2.3で追加された「reset と kill」についてです。
- サンプルコード
#include <stdio.h> #include <systemc.h> SC_MODULE( hoge ){ sc_event ev; sc_process_handle t; int q; SC_CTOR( hoge ) { SC_THREAD( calling ); SC_THREAD( target ); t = sc_get_current_process_handle(); } void calling(){ wait(10, SC_NS); ev.notify(); wait(10, SC_NS); t.reset(); wait(10, SC_NS); ev.notify(); wait(10, SC_NS); t.kill(); assert( t.terminated() ); wait(10, SC_NS); ev.notify(); } void target(){ q = 0; while (1) { wait(ev); ++q; cout << sc_time_stamp(); cout << " q = " << q << endl; } } }; int sc_main(int argc, char *argv[]) { hoge mhoge("hoge"); sc_start(500, sc_core::SC_NS); return 0; }
- 実行結果
$> ./main SystemC 2.3.0-ASI --- Dec 14 2012 21:01:01 Copyright (c) 1996-2012 by all Contributors, ALL RIGHTS RESERVED 10 ns q = 1 30 ns q = 1
kill実行後はtargetプロセスが動作していないことがわかると思います。