process.cc (13335:299a16ef8e3c) | process.cc (13489:8b0666946c20) |
---|---|
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 --- 67 unchanged lines hidden (view full) --- 76} 77 78void 79Process::suspend(bool inc_kids) 80{ 81 if (inc_kids) 82 forEachKid([](Process *p) { p->suspend(true); }); 83 | 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 --- 67 unchanged lines hidden (view full) --- 76} 77 78void 79Process::suspend(bool inc_kids) 80{ 81 if (inc_kids) 82 forEachKid([](Process *p) { p->suspend(true); }); 83 |
84 if (!_suspended) { | 84 if (!_suspended && !_terminated) { |
85 _suspended = true; 86 _suspendedReady = scheduler.suspend(this); 87 88 if (procKind() != ::sc_core::SC_METHOD_PROC_ && 89 scheduler.current() == this) { 90 // This isn't in the spec, but Accellera says that a thread that 91 // self suspends should be marked ready immediately when it's 92 // resumed. --- 4 unchanged lines hidden (view full) --- 97} 98 99void 100Process::resume(bool inc_kids) 101{ 102 if (inc_kids) 103 forEachKid([](Process *p) { p->resume(true); }); 104 | 85 _suspended = true; 86 _suspendedReady = scheduler.suspend(this); 87 88 if (procKind() != ::sc_core::SC_METHOD_PROC_ && 89 scheduler.current() == this) { 90 // This isn't in the spec, but Accellera says that a thread that 91 // self suspends should be marked ready immediately when it's 92 // resumed. --- 4 unchanged lines hidden (view full) --- 97} 98 99void 100Process::resume(bool inc_kids) 101{ 102 if (inc_kids) 103 forEachKid([](Process *p) { p->resume(true); }); 104 |
105 if (_suspended) { | 105 if (_suspended && !_terminated) { |
106 _suspended = false; 107 if (_suspendedReady) 108 scheduler.resume(this); 109 _suspendedReady = false; 110 } 111} 112 113void --- 5 unchanged lines hidden (view full) --- 119 if (!::sc_core::sc_allow_process_control_corners && 120 timeoutEvent.scheduled()) { 121 std::string message("attempt to disable a thread with timeout wait: "); 122 message += name(); 123 SC_REPORT_ERROR(sc_core::SC_ID_PROCESS_CONTROL_CORNER_CASE_, 124 message.c_str()); 125 } 126 | 106 _suspended = false; 107 if (_suspendedReady) 108 scheduler.resume(this); 109 _suspendedReady = false; 110 } 111} 112 113void --- 5 unchanged lines hidden (view full) --- 119 if (!::sc_core::sc_allow_process_control_corners && 120 timeoutEvent.scheduled()) { 121 std::string message("attempt to disable a thread with timeout wait: "); 122 message += name(); 123 SC_REPORT_ERROR(sc_core::SC_ID_PROCESS_CONTROL_CORNER_CASE_, 124 message.c_str()); 125 } 126 |
127 _disabled = true; | 127 if (!_terminated) 128 _disabled = true; |
128} 129 130void 131Process::enable(bool inc_kids) 132{ 133 134 if (inc_kids) 135 forEachKid([](Process *p) { p->enable(true); }); 136 | 129} 130 131void 132Process::enable(bool inc_kids) 133{ 134 135 if (inc_kids) 136 forEachKid([](Process *p) { p->enable(true); }); 137 |
137 _disabled = false; | 138 if (!_terminated) 139 _disabled = false; |
138} 139 140void 141Process::kill(bool inc_kids) 142{ 143 if (::sc_core::sc_get_status() != ::sc_core::SC_RUNNING) { 144 SC_REPORT_ERROR(sc_core::SC_ID_KILL_PROCESS_WHILE_UNITIALIZED_, 145 name()); 146 } 147 148 // Propogate the kill to our children no matter what happens to us. 149 if (inc_kids) 150 forEachKid([](Process *p) { p->kill(true); }); 151 | 140} 141 142void 143Process::kill(bool inc_kids) 144{ 145 if (::sc_core::sc_get_status() != ::sc_core::SC_RUNNING) { 146 SC_REPORT_ERROR(sc_core::SC_ID_KILL_PROCESS_WHILE_UNITIALIZED_, 147 name()); 148 } 149 150 // Propogate the kill to our children no matter what happens to us. 151 if (inc_kids) 152 forEachKid([](Process *p) { p->kill(true); }); 153 |
152 // If we're in the middle of unwinding, ignore the kill request. 153 if (_isUnwinding) | 154 // If we're unwinding or terminated, ignore the kill request. 155 if (_isUnwinding || _terminated) |
154 return; 155 156 // Update our state. 157 terminate(); 158 _isUnwinding = true; 159 160 // Make sure this process isn't marked ready 161 popListNode(); --- 10 unchanged lines hidden (view full) --- 172 SC_REPORT_ERROR(sc_core::SC_ID_RESET_PROCESS_WHILE_NOT_RUNNING_, 173 name()); 174 } 175 176 // Propogate the reset to our children no matter what happens to us. 177 if (inc_kids) 178 forEachKid([](Process *p) { p->reset(true); }); 179 | 156 return; 157 158 // Update our state. 159 terminate(); 160 _isUnwinding = true; 161 162 // Make sure this process isn't marked ready 163 popListNode(); --- 10 unchanged lines hidden (view full) --- 174 SC_REPORT_ERROR(sc_core::SC_ID_RESET_PROCESS_WHILE_NOT_RUNNING_, 175 name()); 176 } 177 178 // Propogate the reset to our children no matter what happens to us. 179 if (inc_kids) 180 forEachKid([](Process *p) { p->reset(true); }); 181 |
180 // If we're in the middle of unwinding, ignore the reset request. 181 if (_isUnwinding) | 182 // If we're already unwinding or terminated, ignore the reset request. 183 if (_isUnwinding || _terminated) |
182 return; 183 184 // Clear suspended ready since we're about to run regardless. 185 _suspendedReady = false; 186 187 _resetEvent.notify(); 188 189 if (_needsStart) { --- 250 unchanged lines hidden --- | 184 return; 185 186 // Clear suspended ready since we're about to run regardless. 187 _suspendedReady = false; 188 189 _resetEvent.notify(); 190 191 if (_needsStart) { --- 250 unchanged lines hidden --- |