38 # include <rtai_config.h> 39 # include <rtai_lxrt.h> 40 # include <rtai_posix.h> 41 # include <rtai_version.h> 42 # if defined(_SYSTEM_LXRT_33_) || defined(_SYSTEM_LXRT_35_) 43 # include <mca_lxrt_extension.h> 53 #define LOCAL_PRINTF(arg) 77 LOCAL_PRINTF(
"LXRT shutdown: Making the task plain Linux ... ");
85 std::ifstream modules(
"/proc/modules");
87 while (modules.good())
89 memset(line, 0,
sizeof(line));
90 modules.getline(line, 200);
91 if (!strncmp(line, name, strlen(name)))
102 # if defined(_SYSTEM_LXRT_33_) || defined(_SYSTEM_LXRT_35_) 105 printf(
"LXRT: No mca_lxrt_extension module loaded\n LXRT functions not available!\n");
111 printf(
"LXRT: No rtai_hal module loaded\n LXRT functions not available!\n");
116 printf(
"LXRT: No rtai_lxrt module loaded\n LXRT functions not available!\n");
121 printf(
"LXRT: No rtai_sem module loaded\n LXRT functions not available!\n");
127 if (!global_lxrt_available)
129 printf(
"LXRT: available\n");
132 global_lxrt_available = 1;
153 return global_lxrt_available && rt_buddy();
162 return global_lxrt_available && rt_buddy() && rt_is_hard_real_time(rt_buddy());
173 rt_make_soft_real_time();
183 rt_make_hard_real_time();
190 if (!global_lxrt_available)
192 printf(
"LXRT not available: MakeThisAnLXRTTask impossible\n");
199 printf(
"LXRT: this is alread an lxrt task\n");
203 rt_allow_nonroot_hrt();
206 if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0)
208 perror(
"LXRT: Could not lock the process memory:");
213 struct sched_param mysched;
214 mysched.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
215 if (sched_setscheduler(0, SCHED_FIFO, &mysched) == -1)
217 printf(
"LXRT: ERROR IN SETTING THE SCHEDULER");
218 perror(
"LXRT: errno");
222 if (!rt_task_init(
getpid() + pthread_self_rt(), 100, 0, 0))
224 printf(
"LXRT: CANNOT INIT THREAD \n");
228 if ((hard_timer_running = rt_is_hard_timer_running()))
230 printf(
"WARNING: Timer is already on - not activating.");
234 #if CONFIG_RTAI_VERSION_MINOR < 5 235 rt_set_periodic_mode();
239 rt_set_oneshot_mode();
241 int hp = start_rt_timer(nano2count(500000));
242 printf(
"LXRT: starting TIMER with hp = %i", hp);
247 printf(
"LXRT: Not compiled for LXRT: Cannot switch this task into an lxrt one.\n");
260 rt_make_soft_real_time();
263 #if CONFIG_RTAI_VERSION_MINOR < 5 264 RT_TASK *rt_task = rt_buddy();
267 rt_task_delete(rt_task);
270 pthread_join_rt(pthread_self_rt(), NULL);
294 printf(
"LXRT: Not compiled for LXRT: Cannot switch this task from LXRT to linux.\n");
300 struct timeval lxrtGetExecTime()
303 # if defined(_SYSTEM_LXRT_33_) || defined(_SYSTEM_LXRT_35_) 304 mcalxrt_exectime(&time);
307 rt_get_exectime(rt_agent(), exectime);
309 count2timespec(exectime[0], &ts);
311 time.tv_usec = ts.
tv_nsec / 1000;
318 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
bool checkKernelModule(const char *name)
Contains global LXRT functions.
void * memset(void *dest, int c, size_t count)
bool global_lxrt_available
#define LOCAL_PRINTF(arg)
void makeThisALinuxTask()
struct timeval ICL_CORE_IMPORT_EXPORT lxrtGetExecTime()