scheduler.hh (13244:deedec45898f) | scheduler.hh (13245:c666c5d4996b) |
---|---|
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 | 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 |
|
51typedef NodeList<Process> ProcessList; 52typedef NodeList<Channel> ChannelList; 53 54/* 55 * The scheduler supports three different mechanisms, the initialization phase, 56 * delta cycles, and timed notifications. 57 * 58 * INITIALIZATION PHASE --- 216 unchanged lines hidden (view full) --- 275 void 276 completeTimeSlot(TimeSlot *ts) 277 { 278 _changeStamp++; 279 assert(ts == timeSlots.begin()->second); 280 timeSlots.erase(timeSlots.begin()); 281 if (!runToTime && starved()) 282 scheduleStarvationEvent(); | 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(); |
|
283 } 284 285 // Pending activity ignores gem5 activity, much like how a systemc 286 // simulation wouldn't know about asynchronous external events (socket IO 287 // for instance) that might happen before time advances in a pure 288 // systemc simulation. Also the spec lists what specific types of pending 289 // activity needs to be counted, which obviously doesn't include gem5 290 // events. --- 61 unchanged lines hidden (view full) --- 352 353 uint64_t changeStamp() { return _changeStamp; } 354 355 void throwToScMain(const ::sc_core::sc_report *r=nullptr); 356 357 Status status() { return _status; } 358 void status(Status s) { _status = s; } 359 | 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 |
|
360 private: 361 typedef const EventBase::Priority Priority; 362 static Priority DefaultPriority = EventBase::Default_Pri; 363 364 static Priority StopPriority = DefaultPriority - 1; 365 static Priority PausePriority = DefaultPriority + 1; 366 static Priority MaxTickPriority = DefaultPriority + 2; 367 static Priority ReadyPriority = DefaultPriority + 3; 368 static Priority StarvationPriority = ReadyPriority; | 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; |
|
369 370 EventQueue *eq; 371 372 // For gem5 style events. 373 void 374 schedule(::Event *event, Tick tick) 375 { 376 if (initDone) --- 58 unchanged lines hidden (view full) --- 435 maxTickFunc() 436 { 437 if (lastReadyTick != getCurTick()) 438 _changeStamp++; 439 pause(); 440 } 441 EventWrapper<Scheduler, &Scheduler::maxTickFunc> maxTickEvent; 442 | 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 |
|
443 uint64_t _numCycles; 444 uint64_t _changeStamp; 445 446 Process *_current; 447 448 bool initDone; 449 bool runToTime; 450 bool runOnce; 451 452 ProcessList initList; 453 454 ProcessList readyListMethods; 455 ProcessList readyListThreads; 456 457 ChannelList updateList; 458 459 std::map<::Event *, Tick> eventsToSchedule; | 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); |
|
460}; 461 462extern Scheduler scheduler; 463 464inline void 465Scheduler::TimeSlot::process() 466{ 467 scheduler.status(StatusTiming); --- 21 unchanged lines hidden --- | 480}; 481 482extern Scheduler scheduler; 483 484inline void 485Scheduler::TimeSlot::process() 486{ 487 scheduler.status(StatusTiming); --- 21 unchanged lines hidden --- |