process.hh (12952:94fca7e8120b) process.hh (12953:ddfd5e4643a9)
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 19 unchanged lines hidden (view full) ---

28 */
29
30#ifndef __SYSTEMC_CORE_PROCESS_HH__
31#define __SYSTEMC_CORE_PROCESS_HH__
32
33#include <functional>
34
35#include "base/fiber.hh"
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 19 unchanged lines hidden (view full) ---

28 */
29
30#ifndef __SYSTEMC_CORE_PROCESS_HH__
31#define __SYSTEMC_CORE_PROCESS_HH__
32
33#include <functional>
34
35#include "base/fiber.hh"
36#include "systemc/core/list.hh"
36#include "systemc/core/object.hh"
37#include "systemc/ext/core/sc_event.hh"
38#include "systemc/ext/core/sc_module.hh"
39#include "systemc/ext/core/sc_process_handle.hh"
40
41namespace sc_gem5
42{
43
37#include "systemc/core/object.hh"
38#include "systemc/ext/core/sc_event.hh"
39#include "systemc/ext/core/sc_module.hh"
40#include "systemc/ext/core/sc_process_handle.hh"
41
42namespace sc_gem5
43{
44
44class Process : public ::sc_core::sc_object
45class Process : public ::sc_core::sc_object, public ListNode
45{
46 public:
47 virtual ::sc_core::sc_curr_proc_kind procKind() const = 0;
46{
47 public:
48 virtual ::sc_core::sc_curr_proc_kind procKind() const = 0;
49 bool running() const { return _running; }
48 bool dynamic() const { return _dynamic; }
49 bool isUnwinding() const { return _isUnwinding; }
50 bool terminated() const { return _terminated; }
51
52 void forEachKid(const std::function<void(Process *)> &work);
53
54 bool suspended() const { return _suspended; }
55 bool disabled() const { return _disabled; }

--- 14 unchanged lines hidden (view full) ---

70 void syncResetOff(bool inc_kids);
71
72 void incref() { refCount++; }
73 void decref() { refCount--; }
74
75 const ::sc_core::sc_event &resetEvent() { return _resetEvent; }
76 const ::sc_core::sc_event &terminatedEvent() { return _terminatedEvent; }
77
50 bool dynamic() const { return _dynamic; }
51 bool isUnwinding() const { return _isUnwinding; }
52 bool terminated() const { return _terminated; }
53
54 void forEachKid(const std::function<void(Process *)> &work);
55
56 bool suspended() const { return _suspended; }
57 bool disabled() const { return _disabled; }

--- 14 unchanged lines hidden (view full) ---

72 void syncResetOff(bool inc_kids);
73
74 void incref() { refCount++; }
75 void decref() { refCount--; }
76
77 const ::sc_core::sc_event &resetEvent() { return _resetEvent; }
78 const ::sc_core::sc_event &terminatedEvent() { return _terminatedEvent; }
79
80 // This should only be called before initialization.
81 void dontInitialize() { popListNode(); }
82
83 void setStackSize(size_t size) { stackSize = size; }
84
85 void run();
86
87 virtual Fiber *fiber() { return Fiber::primaryFiber(); }
88
89 static Process *newest() { return _newest; }
90
78 protected:
91 protected:
79 Process(const char *name, ProcessFuncWrapper *func, bool _dynamic) :
80 ::sc_core::sc_object(name), func(func), _dynamic(_dynamic),
81 _isUnwinding(false), _terminated(false), _suspended(false),
82 _disabled(false), _syncReset(false), refCount(0)
83 {}
92 Process(const char *name, ProcessFuncWrapper *func, bool _dynamic);
84
93
94 static Process *_newest;
95
85 virtual ~Process() { delete func; }
86
87 ::sc_core::sc_event _resetEvent;
88 ::sc_core::sc_event _terminatedEvent;
89
90 ProcessFuncWrapper *func;
91 sc_core::sc_curr_proc_kind _procKind;
96 virtual ~Process() { delete func; }
97
98 ::sc_core::sc_event _resetEvent;
99 ::sc_core::sc_event _terminatedEvent;
100
101 ProcessFuncWrapper *func;
102 sc_core::sc_curr_proc_kind _procKind;
103 bool _running;
92 bool _dynamic;
93 bool _isUnwinding;
94 bool _terminated;
95
96 bool _suspended;
97 bool _disabled;
98
99 bool _syncReset;
100
101 int refCount;
104 bool _dynamic;
105 bool _isUnwinding;
106 bool _terminated;
107
108 bool _suspended;
109 bool _disabled;
110
111 bool _syncReset;
112
113 int refCount;
102};
103
114
104class Method : public Process
105{
106 public:
107 Method(const char *name, ProcessFuncWrapper *func, bool _dynamic=false) :
108 Process(name, func, _dynamic)
109 {}
110
111 const char *kind() const override { return "sc_method_process"; }
112
113 sc_core::sc_curr_proc_kind
114 procKind() const override
115 {
116 return sc_core::SC_METHOD_PROC_;
117 }
115 size_t stackSize;
118};
119
116};
117
120class Thread : public Process
121{
122 public:
123 Thread(const char *name, ProcessFuncWrapper *func, bool _dynamic=false) :
124 Process(name, func, _dynamic)
125 {}
126
127 const char *kind() const override { return "sc_thread_process"; }
128
129 void throw_it(ExceptionWrapperBase &exc, bool inc_kids) override;
130
131 sc_core::sc_curr_proc_kind
132 procKind() const override
133 {
134 return sc_core::SC_THREAD_PROC_;
135 }
136};
137
138class CThread : public Thread
139{
140 public:
141 CThread(const char *name, ProcessFuncWrapper *func, bool _dynamic=false) :
142 Thread(name, func, _dynamic)
143 {}
144
145 const char *kind() const override { return "sc_cthread_process"; }
146
147 sc_core::sc_curr_proc_kind
148 procKind() const override
149 {
150 return sc_core::SC_CTHREAD_PROC_;
151 }
152};
153
154} // namespace sc_gem5
155
156#endif //__SYSTEMC_CORE_PROCESS_HH__
118} // namespace sc_gem5
119
120#endif //__SYSTEMC_CORE_PROCESS_HH__