27 #include <coil/stringutil.h> 29 #define MAX_SAFE_STACK (8*1024) 30 #define NSEC_PER_SEC 1000000000 43 m_priority(49), m_policy(SCHED_FIFO), m_waitoffset(0)
56 getProperty(prop,
"exec_cxt.periodic.rtpreempt.sched_policy", policy);
60 if (policy ==
"rr") {
m_policy = SCHED_RR; }
61 if (policy ==
"fifo") {
m_policy = SCHED_FIFO; }
62 RTC_DEBUG((
"Scheduling policy: %s", policy.c_str()));
97 struct sched_param param;
99 if(sched_setscheduler(0,
m_policy, ¶m) == -1)
101 std::cerr <<
"sched_setscheduler failed" << std::endl;
106 if(mlockall(MCL_CURRENT | MCL_FUTURE) == -1)
108 std::cerr <<
"mlockall failed" << std::endl;
115 struct timespec t0, t1, t;
118 clock_gettime(CLOCK_MONOTONIC ,&t0);
129 clock_gettime(CLOCK_MONOTONIC ,&t1);
133 if (t0.tv_nsec > t1.tv_nsec)
138 - (t1.tv_sec - 1 - t0.tv_sec);
145 - (t1.tv_sec - t0.tv_sec);
148 if (t.tv_nsec < 0 || t.tv_sec < 0)
150 std::cerr <<
"faital error: deadline passed. " << std::endl;
151 std::cerr <<
"Wait time: ";
152 std::cerr << t.tv_sec <<
"[s], ";
153 std::cerr << t.tv_nsec <<
"[ns]" << std::endl;
154 std::cerr <<
"Next wait time force to: 0.0 [s]" << std::endl;
157 clock_nanosleep(CLOCK_MONOTONIC, !TIMER_ABSTIME, &t, NULL);
179 registerECFactory(
"RTPreemptEC",
180 RTC::ECCreate<OpenRTM::RTPreemptEC>,
181 RTC::ECDelete<OpenRTM::RTPreemptEC>);
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
long int sec() const
Get value of second time scale.
std::vector< Comp > m_comps
List of the participating component.
bool m_svc
The thread running flag of ExecutionContext.
void setName(const char *name)
Set suffix of date/time string of header.
Functor to invoke worker.
static Manager & instance()
Get instance of the manager.
RTComponent manager class.
Worker m_worker
A condition variable for external triggered worker.
void getProperty(coil::Properties &prop, const char *key, T &value)
Thread execution function for ExecutionContext.
bool m_nowait
Flag of ExecutionContext to run immediately (to run without waiting)
#define RTC_DEBUG(fmt)
Debug level log output macro.
virtual ~RTPreemptEC()
Destructor.
coil::Condition< coil::Mutex > cond_
prop
Organization::get_organization_property ();.
Class represents a set of properties.
Logger rtclog
Logger stream.
ExecutionContext Factory class.
RTPreemptEC()
Default Constructor.
void RTPreemptECInit(RTC::Manager *manager)
Initialization function to register to ECFactory.
long int usec() const
Get value of micro second time scale.
virtual int svc(void)
Thread execution function for ExecutionContext.
coil::TimeValue m_period
Execution cycle of ExecutionContext.
Functor for_each(CorbaSequence &seq, Functor f)
Apply the functor to all CORBA sequence elements.