MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
rtsolver.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  RTSolverBase
 

Functions

void ReadRTParams (Solver *pS, MBDynParser &HP, RTSolverBase::RTMode &eRTMode, unsigned long &lRTPeriod, unsigned long &RTStackSize, bool &bRTAllowNonRoot, int &RTCpuMap)
 
RTSolverBaseReadRTSolver (Solver *pS, MBDynParser &HP)
 

Function Documentation

void ReadRTParams ( Solver pS,
MBDynParser HP,
RTSolverBase::RTMode eRTMode,
unsigned long &  lRTPeriod,
unsigned long &  RTStackSize,
bool bRTAllowNonRoot,
int RTCpuMap 
)

Definition at line 89 of file rtsolver.cc.

References buf, get_nprocs(), HighParser::GetInt(), IncludeParser::GetLineData(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, RTSolverBase::MBRT_IO, RTSolverBase::MBRT_SEMAPHORE, RTSolverBase::MBRT_UNKNOWN, and RTSolverBase::MBRT_WAITPERIOD.

Referenced by ReadRTAISolver(), and ReadRTPOSIXSolver().

95 {
97  /* FIXME: use a safe default? */
98  if (HP.IsKeyWord("mode")) {
99  if (HP.IsKeyWord("period")) {
101 
102  } else if (HP.IsKeyWord("semaphore")) {
103  /* FIXME: not implemented yet ... */
105 
106  } else if (HP.IsKeyWord("io")) {
107  eRTMode = RTSolverBase::MBRT_IO;
108 
109  } else {
110  silent_cerr("RTSolver: unknown realtime mode "
111  "at line " << HP.GetLineData()
112  << std::endl);
114  }
115  }
116 
117  switch (eRTMode) {
120  silent_cerr("RTSolver: unknown realtime mode; "
121  "assuming periodic "
122  "at line " << HP.GetLineData()
123  << std::endl);
124  // fallthru
125 
127  lRTPeriod = -1;
128  if (HP.IsKeyWord("time" "step")) {
129  long long p = HP.GetInt();
130 
131  if (p <= 0) {
132  silent_cerr("RTSolver: illegal time step "
133  << p << " at line "
134  << HP.GetLineData()
135  << std::endl);
137  }
138 
139  lRTPeriod = p;
140 
141  } else {
142  silent_cerr("RTSolver: need a time step for real time "
143  "at line " << HP.GetLineData()
144  << std::endl);
146  }
147  break;
148 
150  // impossible, right now
151  break;
152 
154  break;
155 
156  default:
158  }
159 
160  RTStackSize = 1024;
161  if (HP.IsKeyWord("reserve" "stack")) {
162  long size = HP.GetInt();
163 
164  if (size <= 0) {
165  silent_cerr("RTSolver: illegal stack size "
166  << size << " at line "
167  << HP.GetLineData()
168  << std::endl);
170  }
171 
172  RTStackSize = size;
173  }
174 
175  bRTAllowNonRoot = false;
176  if (HP.IsKeyWord("allow" "nonroot")) {
177  bRTAllowNonRoot = true;
178  }
179 
180  RTCpuMap = 0xFF;
181  if (HP.IsKeyWord("cpu" "map")) {
182 #ifndef HAVE_SCHED_SETAFFINITY
183  silent_cerr("warning: \"cpu map\" unsupported (ignored)" << std::endl);
184 #endif // ! HAVE_SCHED_SETAFFINITY
185 
186  int cpumap = HP.GetInt();
187  // NOTE: there is a hard limit at 4 CPU
188  int ncpu = std::min(get_nprocs(), 4);
189  int newcpumap = (2 << (ncpu - 1)) - 1;
190 
191  /* i bit non legati ad alcuna cpu sono posti a zero */
192  newcpumap &= cpumap;
193  if (newcpumap < 1 || newcpumap > 0xFF) {
194  char buf[16];
195  snprintf(buf, sizeof(buf), "0x%02X", (unsigned)cpumap);
196  silent_cerr("RTSolver: illegal cpu map " << buf
197  << " at line " << HP.GetLineData()
198  << std::endl);
200  }
201  RTCpuMap = newcpumap;
202  }
203 }
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
virtual integer GetInt(integer iDefval=0)
Definition: parser.cc:1050
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
int get_nprocs(void)
Definition: get_nprocs.c:44
static doublereal buf[BUFSIZE]
Definition: discctrl.cc:333
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function:

RTSolverBase* ReadRTSolver ( Solver pS,
MBDynParser HP 
)

Definition at line 206 of file rtsolver.cc.

References IncludeParser::GetLineData(), HighParser::IsKeyWord(), MBDYN_EXCEPT_ARGS, ReadRTAISolver(), and ReadRTPOSIXSolver().

Referenced by InverseSolver::ReadData(), and Solver::ReadData().

207 {
208  if (HP.IsKeyWord("POSIX")) {
209  return ReadRTPOSIXSolver(pS, HP);
210  }
211 
212 #ifdef USE_RTAI
213  if (!HP.IsKeyWord("RTAI")) {
214  pedantic_cerr("ReadRTSolver: missing real-time model; "
215  "assuming RTAI at line " << HP.GetLineData()
216  << std::endl);
217  }
218 
219  return ReadRTAISolver(pS, HP);
220 
221 #else // ! USE_RTAI
222  if (HP.IsKeyWord("RTAI")) {
223  silent_cerr("ReadRTSolver: need to configure --with-rtai "
224  "to use RTAI real-time solver "
225  "at line " << HP.GetLineData() << std::endl);
226 
227  } else {
228  silent_cerr("ReadRTSolver: need to configure --with-rtai "
229  "to use default RTAI real-time solver "
230  "at line " << HP.GetLineData() << std::endl);
231  }
232 
234 #endif // ! USE_RTAI
235 }
RTSolverBase * ReadRTPOSIXSolver(Solver *pS, MBDynParser &HP)
#define MBDYN_EXCEPT_ARGS
Definition: except.h:63
RTSolverBase * ReadRTAISolver(Solver *pS, MBDynParser &HP)
Definition: rtaisolver.cc:377
virtual bool IsKeyWord(const char *sKeyWord)
Definition: parser.cc:910
virtual HighParser::ErrOut GetLineData(void) const
Definition: parsinc.cc:697

Here is the call graph for this function: