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 --- 34 unchanged lines hidden (view full) --- 43#include "systemc/core/process.hh" 44#include "systemc/core/sched_event.hh" 45 46class Fiber; 47 48namespace sc_gem5 49{ 50 |
51class TraceFile; 52 |
53typedef NodeList<Process> ProcessList; 54typedef NodeList<Channel> ChannelList; 55 56/* 57 * The scheduler supports three different mechanisms, the initialization phase, 58 * delta cycles, and timed notifications. 59 * 60 * INITIALIZATION PHASE --- 216 unchanged lines hidden (view full) --- 277 void 278 completeTimeSlot(TimeSlot *ts) 279 { 280 _changeStamp++; 281 assert(ts == timeSlots.begin()->second); 282 timeSlots.erase(timeSlots.begin()); 283 if (!runToTime && starved()) 284 scheduleStarvationEvent(); |
285 scheduleTimeAdvancesEvent(); |
286 } 287 288 // Pending activity ignores gem5 activity, much like how a systemc 289 // simulation wouldn't know about asynchronous external events (socket IO 290 // for instance) that might happen before time advances in a pure 291 // systemc simulation. Also the spec lists what specific types of pending 292 // activity needs to be counted, which obviously doesn't include gem5 293 // events. --- 61 unchanged lines hidden (view full) --- 355 356 uint64_t changeStamp() { return _changeStamp; } 357 358 void throwToScMain(const ::sc_core::sc_report *r=nullptr); 359 360 Status status() { return _status; } 361 void status(Status s) { _status = s; } 362 |
363 void registerTraceFile(TraceFile *tf) { traceFiles.insert(tf); } 364 void unregisterTraceFile(TraceFile *tf) { traceFiles.erase(tf); } 365 |
366 private: 367 typedef const EventBase::Priority Priority; 368 static Priority DefaultPriority = EventBase::Default_Pri; 369 370 static Priority StopPriority = DefaultPriority - 1; 371 static Priority PausePriority = DefaultPriority + 1; 372 static Priority MaxTickPriority = DefaultPriority + 2; 373 static Priority ReadyPriority = DefaultPriority + 3; 374 static Priority StarvationPriority = ReadyPriority; |
375 static Priority TimeAdvancesPriority = EventBase::Maximum_Pri; |
376 377 EventQueue *eq; 378 379 // For gem5 style events. 380 void 381 schedule(::Event *event, Tick tick) 382 { 383 if (initDone) --- 58 unchanged lines hidden (view full) --- 442 maxTickFunc() 443 { 444 if (lastReadyTick != getCurTick()) 445 _changeStamp++; 446 pause(); 447 } 448 EventWrapper<Scheduler, &Scheduler::maxTickFunc> maxTickEvent; 449 |
450 void timeAdvances() { trace(false); } 451 EventWrapper<Scheduler, &Scheduler::timeAdvances> timeAdvancesEvent; 452 void 453 scheduleTimeAdvancesEvent() 454 { 455 if (!traceFiles.empty() && !timeAdvancesEvent.scheduled()) 456 schedule(&timeAdvancesEvent); 457 } 458 |
459 uint64_t _numCycles; 460 uint64_t _changeStamp; 461 462 Process *_current; 463 464 bool initDone; 465 bool runToTime; 466 bool runOnce; 467 468 ProcessList initList; 469 470 ProcessList readyListMethods; 471 ProcessList readyListThreads; 472 473 ChannelList updateList; 474 475 std::map<::Event *, Tick> eventsToSchedule; |
476 477 std::set<TraceFile *> traceFiles; 478 479 void trace(bool delta); |
480}; 481 482extern Scheduler scheduler; 483 484inline void 485Scheduler::TimeSlot::process() 486{ 487 scheduler.status(StatusTiming); --- 21 unchanged lines hidden --- |