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 --- 183 unchanged lines hidden (view full) --- 192 193 // Schedule an update for a given channel. 194 void requestUpdate(Channel *c); 195 196 // Run the given process immediately, preempting whatever may be running. 197 void 198 runNow(Process *p) 199 { |
200 // This function may put a process on the wrong list, ie a method on 201 // the process list or vice versa. That's fine since that's just a 202 // performance optimization, and the important thing here is how the 203 // processes are ordered. 204 |
205 // If a process is running, schedule it/us to run again. 206 if (_current) |
207 readyList->pushFirst(_current); |
208 // Schedule p to run first. |
209 readyList->pushFirst(p); |
210 yield(); 211 } 212 213 // Set an event queue for scheduling events. 214 void setEventQueue(EventQueue *_eq) { eq = _eq; } 215 216 // Get the current time according to gem5. 217 Tick getCurTick() { return eq ? eq->getCurTick() : 0; } --- 72 unchanged lines hidden (view full) --- 290 // systemc simulation. Also the spec lists what specific types of pending 291 // activity needs to be counted, which obviously doesn't include gem5 292 // events. 293 294 // Return whether there's pending systemc activity at this time. 295 bool 296 pendingCurr() 297 { |
298 return !readyListMethods.empty() || !readyListThreads.empty() || 299 !updateList.empty() || !deltas.empty(); |
300 } 301 302 // Return whether there are pending timed notifications or timeouts. 303 bool 304 pendingFuture() 305 { 306 return !timeSlots.empty(); 307 } --- 69 unchanged lines hidden (view full) --- 377 void stop(); 378 EventWrapper<Scheduler, &Scheduler::pause> pauseEvent; 379 EventWrapper<Scheduler, &Scheduler::stop> stopEvent; 380 Fiber *scMain; 381 382 bool 383 starved() 384 { |
385 return (readyListMethods.empty() && readyListThreads.empty() && 386 updateList.empty() && deltas.empty() && |
387 (timeSlots.empty() || timeSlots.begin()->first > maxTick) && 388 initList.empty()); 389 } 390 EventWrapper<Scheduler, &Scheduler::pause> starvationEvent; 391 void scheduleStarvationEvent(); 392 393 bool _started; 394 bool _paused; --- 17 unchanged lines hidden (view full) --- 412 Process *_current; 413 414 bool initDone; 415 bool runToTime; 416 bool runOnce; 417 418 ProcessList initList; 419 ProcessList toFinalize; |
420 |
421 ProcessList *readyList; 422 ProcessList readyListMethods; 423 ProcessList readyListThreads; 424 |
425 ChannelList updateList; 426 427 std::map<::Event *, Tick> eventsToSchedule; 428}; 429 430extern Scheduler scheduler; 431 432inline void 433Scheduler::TimeSlot::process() 434{ 435 while (!events.empty()) 436 events.front()->run(); 437 scheduler.completeTimeSlot(this); 438} 439 440} // namespace sc_gem5 441 442#endif // __SYSTEMC_CORE_SCHEDULER_H__ |