26
|
1 |
TaskManager refactor: avoid using Simulator::Schedule()
|
|
2 |
|
|
3 |
diff --git a/model/dce.cc b/model/dce.cc
|
|
4 |
--- a/model/dce.cc
|
|
5 |
+++ b/model/dce.cc
|
|
6 |
@@ -502,8 +502,9 @@
|
|
7 |
{
|
|
8 |
if (!process->itimerInterval.IsZero ())
|
|
9 |
{
|
|
10 |
- process->itimer = Simulator::Schedule (process->itimerInterval,
|
|
11 |
- &Itimer, process);
|
|
12 |
+ process->itimer = Simulator::ScheduleWithContext (Simulator::GetContext (),
|
|
13 |
+ process->itimerInterval,
|
|
14 |
+ &Itimer, process);
|
|
15 |
}
|
|
16 |
// wakeup one thread
|
|
17 |
UtilsSendSignal (process, SIGALRM);
|
|
18 |
@@ -551,8 +552,9 @@
|
|
19 |
{
|
|
20 |
return 0;
|
|
21 |
}
|
|
22 |
- current->process->itimer = Simulator::Schedule (UtilsTimevalToTime (value->it_value),
|
|
23 |
- &Itimer, current->process);
|
|
24 |
+ current->process->itimer = Simulator::ScheduleWithContext (Simulator::GetContext (),
|
|
25 |
+ UtilsTimevalToTime (value->it_value),
|
|
26 |
+ &Itimer, current->process);
|
|
27 |
return 0;
|
|
28 |
}
|
|
29 |
char * dce_getcwd (char *buf, size_t size)
|
|
30 |
diff --git a/model/linux-socket-fd-factory.cc b/model/linux-socket-fd-factory.cc
|
|
31 |
--- a/model/linux-socket-fd-factory.cc
|
|
32 |
+++ b/model/linux-socket-fd-factory.cc
|
|
33 |
@@ -198,9 +198,9 @@
|
|
34 |
{
|
|
35 |
LinuxSocketFdFactory *self = (LinuxSocketFdFactory *)kernel;
|
|
36 |
Ptr<EventIdHolder> ev = Create<EventIdHolder> ();
|
|
37 |
- EventId event = Simulator::Schedule (NanoSeconds (ns),
|
|
38 |
- &LinuxSocketFdFactory::EventTrampoline,
|
|
39 |
- self, fn, context, pre_fn, ev);
|
|
40 |
+ EventId event = Simulator::ScheduleWithContext (Simulator::GetContext (), NanoSeconds (ns),
|
|
41 |
+ &LinuxSocketFdFactory::EventTrampoline,
|
|
42 |
+ self, fn, context, pre_fn, ev);
|
|
43 |
ev->id = event;
|
|
44 |
return &ev->id;
|
|
45 |
}
|
|
46 |
diff --git a/model/task-manager.cc b/model/task-manager.cc
|
|
47 |
--- a/model/task-manager.cc
|
|
48 |
+++ b/model/task-manager.cc
|
|
49 |
@@ -9,6 +9,7 @@
|
|
50 |
#include "ns3/simulator.h"
|
|
51 |
#include "ns3/node.h"
|
|
52 |
#include "ns3/node-list.h"
|
|
53 |
+#include "ns3/event-id.h"
|
|
54 |
#include "dce-manager.h"
|
|
55 |
#include "dce-stdio.h"
|
|
56 |
#include "process.h"
|
|
57 |
@@ -295,7 +296,8 @@
|
|
58 |
m_scheduler->Enqueue (task);
|
|
59 |
if (!m_nextSchedule.IsRunning ())
|
|
60 |
{
|
|
61 |
- m_nextSchedule = Simulator::ScheduleNow (&TaskManager::Schedule, this);
|
|
62 |
+ m_nextSchedule = Simulator::ScheduleWithContext (Simulator::GetContext (), Seconds (0.0),
|
|
63 |
+ &TaskManager::Schedule, this);
|
|
64 |
}
|
|
65 |
}
|
|
66 |
|
|
67 |
@@ -321,7 +323,9 @@
|
|
68 |
current->m_state = Task::BLOCKED;
|
|
69 |
if (!timeout.IsZero ())
|
|
70 |
{
|
|
71 |
- current->m_waitTimer = Simulator::Schedule (timeout, &TaskManager::EndWait, this, current);
|
|
72 |
+ current->m_waitTimer = Simulator::ScheduleWithContext (Simulator::GetContext (), timeout,
|
|
73 |
+ &TaskManager::EndWait, this, current);
|
|
74 |
+
|
|
75 |
}
|
|
76 |
Schedule ();
|
|
77 |
current->m_waitTimer.Cancel ();
|
|
78 |
@@ -355,7 +359,8 @@
|
|
79 |
m_deadTasks.push_back (current);
|
|
80 |
if (!m_nextGc.IsRunning ())
|
|
81 |
{
|
|
82 |
- m_nextGc = Simulator::ScheduleNow (&TaskManager::GarbageCollectDeadTasks, this);
|
|
83 |
+ m_nextGc = Simulator::ScheduleWithContext (Simulator::GetContext (), Simulator::Now (),
|
|
84 |
+ &TaskManager::GarbageCollectDeadTasks, this);
|
|
85 |
}
|
|
86 |
Schedule ();
|
|
87 |
}
|
|
88 |
@@ -417,7 +422,9 @@
|
|
89 |
{
|
|
90 |
// but before leaving, we check if we have further processes active, and,
|
|
91 |
// if so, make sure we will schedule them later.
|
|
92 |
- Simulator::Schedule (delay, &TaskManager::Schedule, this);
|
|
93 |
+ Thread* thread = (Thread *)next->GetContext ();
|
|
94 |
+ Simulator::ScheduleWithContext (Simulator::GetContext (), delay,
|
|
95 |
+ &TaskManager::Schedule, this);
|
|
96 |
}
|
|
97 |
struct Fiber *fiber = m_current->m_fiber;
|
|
98 |
if (m_current->m_switchNotifier != 0)
|
|
99 |
diff --git a/model/unix-timer-fd.cc b/model/unix-timer-fd.cc
|
|
100 |
--- a/model/unix-timer-fd.cc
|
|
101 |
+++ b/model/unix-timer-fd.cc
|
|
102 |
@@ -207,9 +207,10 @@
|
|
103 |
{
|
|
104 |
if (!m_period.IsZero ())
|
|
105 |
{
|
|
106 |
- m_timer = Simulator::Schedule (m_period,
|
|
107 |
- &UnixTimerFd::TimerExpired,
|
|
108 |
- this);
|
|
109 |
+ m_timer = Simulator::ScheduleWithContext (Simulator::GetContext (),
|
|
110 |
+ m_period,
|
|
111 |
+ &UnixTimerFd::TimerExpired,
|
|
112 |
+ this);
|
|
113 |
}
|
|
114 |
m_skipped++;
|
|
115 |
if (m_waiter != 0)
|
|
116 |
@@ -233,9 +234,10 @@
|
|
117 |
Time initial = UtilsTimespecToTime (new_value->it_value);
|
|
118 |
if (!initial.IsZero ())
|
|
119 |
{
|
|
120 |
- m_timer = Simulator::Schedule (initial,
|
|
121 |
- &UnixTimerFd::TimerExpired,
|
|
122 |
- this);
|
|
123 |
+ m_timer = Simulator::ScheduleWithContext (Simulator::GetContext (),
|
|
124 |
+ initial,
|
|
125 |
+ &UnixTimerFd::TimerExpired,
|
|
126 |
+ this);
|
|
127 |
}
|
|
128 |
return 0;
|
|
129 |
}
|