本文整理汇总了C++中rt_make_hard_real_time函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_make_hard_real_time函数的具体用法?C++ rt_make_hard_real_time怎么用?C++ rt_make_hard_real_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_make_hard_real_time函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: init_module
static int init_module(void)
{
int i, srvport;
while ((srvport = rt_request_hard_port(tasknode)) <= 0) {
msleep(100);
}
printf("START TASK GOT SYNC TASKNODE PORT %lx, %d\n", tasknode, srvport);
rt_make_hard_real_time();
while (!RT_get_adr(tasknode, srvport, task[NUM_TASKS - 1])) {
msleep(100);
}
rt_make_soft_real_time();
printf("START TASK REL SYNC TASKNODE PORT %lx, %d\n", tasknode, srvport);
rt_release_port(tasknode, srvport);
srvport = rt_request_hard_port(comnode);
printf("START TASK GOT INIT COMNODE PORT %lx, %d\n", comnode, srvport);
rt_make_hard_real_time();
print_sem = RT_get_adr(comnode, srvport, "PRTSEM");
sync_sem = RT_get_adr(comnode, srvport, "SYNCSM");
prio_sem = RT_get_adr(comnode, srvport, "PRIOSM");
end_sem = RT_get_adr(comnode, srvport, "ENDSEM");
mbx_in = RT_get_adr(comnode, srvport, "MBXIN");
mbx_out = RT_get_adr(comnode, srvport, "MBXOUT");
for (i = 0; i < NUM_TASKS; ++i) {
sems[i] = RT_get_adr(comnode, srvport, sem[i]);
}
printf("START TASK REL INIT COMNODE PORT %lx, %d\n", comnode, srvport);
rt_make_soft_real_time();
rt_release_port(comnode, srvport);
thread = rt_thread_create(start_task_code, NULL, 10000);
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:33,代码来源:start_task.c
示例2: nam2num
void *init_task_1(void *arg)
{
unsigned long Task_1_name = nam2num("TASK_1");
//TODO:RAWLINSON
if(!(Task_1 = rt_task_init_schmod(Task_1_name,1,0,0,SCHED_FIFO, CPU_ALLOWED))) {
printf("[ERRO] Não foi possível criar a tarefa 1.\n");
exit(1);
}
rt_allow_nonroot_hrt();
rt_make_hard_real_time();
rt_task_make_periodic(Task_1, rt_get_time() + sampling * 5, sampling * 10);
while (1) {
time(&aclock); // Pega tempo em segundos.
newtime = localtime(&aclock);
printf("[TASK 1] =======> %s", asctime(newtime));
rt_task_wait_period();
}
}
开发者ID:nosnilwar,项目名称:rtai-raw-gov-3.9.1,代码行数:25,代码来源:multiple_tasks.c
示例3: main
int main(int argc, char *argv[])
{
int fifo, period, skip, average = 0;
RT_TASK *task;
RTIME expected;
if ((fifo = open("/dev/rtf0", O_WRONLY)) < 0) {
printf("Error opening FIFO0 in UCAL\n");
exit(1);
}
if (!(task = rt_task_init_schmod(nam2num("UCAL"), 0, 0, 0, SCHED_FIFO, 0xF))) {
printf("Cannot init UCAL\n");
exit(1);
}
rt_set_oneshot_mode();
period = start_rt_timer(nano2count(atoi(argv[1])));
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
expected = rt_get_time() + 100*period;
rt_task_make_periodic(task, expected, period);
for (skip = 0; skip < atoi(argv[2]); skip++) {
expected += period;
rt_task_wait_period();
average += (int)count2nano(rt_get_time() - expected);
}
rt_make_soft_real_time();
stop_rt_timer();
rt_task_delete(task);
write(fifo, &average, sizeof(average));
close(fifo);
exit(0);
}
开发者ID:cjecho,项目名称:RTAI,代码行数:33,代码来源:ucal.c
示例4: writing_task_proc
//----------------------------------------------------------------------------
// real time task
void writing_task_proc(void *arg)
{
#ifdef RTAI
writing_task = rt_task_init_schmod(nam2num("WRTSK"),2, 0, 0,
SCHED_FIFO, 0xF);
rt_make_hard_real_time();
#endif
while (1) {
std::list<TPCANMsg>::iterator iter;
for (iter = List->begin(); iter != List->end(); iter++) {
// test for standard frames only
if ((nExtended == CAN_INIT_TYPE_EX) ||
!(iter->MSGTYPE & MSGTYPE_EXTENDED)) {
// send the message
if ((errno = CAN_Write(h, &(*iter))))
shutdownnow = 1;
}
if (shutdownnow == 1)
break;
}
if (shutdownnow == 1)
break;
}
#ifdef RTAI
rt_make_soft_real_time();
rt_task_delete(writing_task);
#endif
}
开发者ID:DKarlberg,项目名称:OpenDaVINCI,代码行数:31,代码来源:transmitest_rt.cpp
示例5: bfun
static void bfun(int t)
{
RT_TASK *mytask;
RT_MSGQ *smbx, *rmbx[NTASKS];
int msg[MAXSIZ + 1], mtype, i, n;
mytask = rt_thread_init(nam2num("BFUN"), 1, 0, SCHED_FIFO, 0xF);
smbx = rt_msgq_init(nam2num("SMSG"), NTASKS, 0);
for (i = 0; i < NTASKS; i++) {
char mname[6] = "RMBX";
mname[4] = i + '0';
mname[5] = 0;
rmbx[i] = rt_msgq_init(nam2num(mname), 1, 0);
}
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
while (!end) {
rt_msg_receive(smbx, msg, sizeof(msg), &mtype);
n = 0;
for (i = 1; i < MAXSIZ; i++) {
n += msg[i];
}
if (msg[MAXSIZ] != n) {
rt_printk("SERVER RECEIVED AN UNKNOWN MSG.\n");
goto prem;
}
msg[1] = 0xFFFFFFFF;
rt_msg_send(rmbx[msg[0]], msg, 2*sizeof(int), 1);
}
prem:
rt_make_soft_real_time();
rt_task_delete(mytask);
printf("SERVER TASK ENDS.\n");
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:35,代码来源:uptestmsg.c
示例6: main
int main(void)
{
RT_TASK *task;
signal(SIGTERM, catch_signal);
signal(SIGINT, catch_signal);
if (!(task = rt_thread_init(nam2num("SWITCH"), 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT SWITCH TASK SIGNAL\n");
exit(1);
}
start_rt_timer(0);
rt_request_signal(SWITCH_SIGNAL, switch_handler);
rt_task_signal_handler(task, (void *)SWITCH_SIGNAL);
rt_make_hard_real_time();
while (!end) {
rt_sleep(nano2count(PERIOD));
}
rt_task_signal_handler(task, NULL);
rt_release_signal(SWITCH_SIGNAL, task);
rt_make_soft_real_time();
stop_rt_timer();
rt_task_delete(task);
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:30,代码来源:user.c
示例7: rt_task_init_schmod
void *thread_fun(void *arg)
{
funtask = rt_task_init_schmod(0xcaccb, 0, 0, 0, SCHED_FIFO, 0x1);
rt_printk("FUN INIT\n");
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
if (!SNDBRCV) {
rt_sleep(nano2count(100000000));
}
if (USE_RPC) {
unsigned long msg;
rt_printk("FUN RPC\n");
rt_rpc(maintask, 0, &msg);
} else {
rt_printk("FUN SEND\n");
rt_send(maintask, 0);
rt_printk("FUN SUSP\n");
rt_task_suspend(funtask);
}
rt_printk("FUN DONE\n");
rt_task_delete(funtask);
rt_printk("FUN END\n");
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:27,代码来源:inhermsg.c
示例8: printf
static void *fast_fun(void *arg)
{
int jit, period;
RTIME expected;
if (!(Fast_Task = rt_thread_init(nam2num("FSTSK"), 2, 0, SCHED_FIFO, CPUMAP))) {
printf("CANNOT INIT FAST TASK\n");
exit(1);
}
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
rt_sem_wait_barrier(barrier);
period = nano2count(FASTMUL*TICK_TIME);
expected = start + 6*nano2count(TICK_TIME);
rt_task_make_periodic(Fast_Task, expected, period);
while (!end) {
jit = abs(count2nano(rt_get_time() - expected));
if (jit > fastjit) {
fastjit = jit;
}
rt_busy_sleep((FASTMUL*TICK_TIME*USEDFRAC)/100);
expected += period;
END("FE\n");
rt_task_wait_period();
BEGIN("FB\n");
}
rt_sem_wait_barrier(barrier);
rt_make_soft_real_time();
rt_thread_delete(Fast_Task);
return 0;
}
开发者ID:ArcEye,项目名称:3.4.55-rtai,代码行数:32,代码来源:preempt.c
示例9: main
int main(void)
{
unsigned long hrttsk_name = nam2num("HRTTSK");
struct sched_param mysched;
mysched.sched_priority = sched_get_priority_max(SCHED_FIFO);
if( sched_setscheduler( 0, SCHED_FIFO, &mysched ) == -1 ) {
puts("ERROR IN SETTING THE SCHEDULER");
perror("errno");
exit(0);
}
if (!(hrttsk = rt_task_init(hrttsk_name, 1, 0, 0))) {
printf("CANNOT INIT TESTB MASTER TASK\n");
exit(1);
}
rt_set_usp_flags_mask(FORCE_SOFT);
rt_task_suspend(hrttsk);
printf("BACKGROUND REAL TIME TASK IS HARD .....\n");
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
while(rt_is_hard_real_time(hrttsk)) {
rt_task_wait_period();
}
printf("..... BACKGROUND REAL TIME TASK IS SOFT NOW, YOU CAN KILL IT BY HAND\n");
rt_task_delete(hrttsk);
while(1) { sleep(3); printf("BACKGROUND PROCESS STILL RUNNING\n"); }
}
开发者ID:cjecho,项目名称:RTAI,代码行数:29,代码来源:rt_task.c
示例10: main
int main(void)
{
RT_TASK *spktsk, *plrtsk;
RTIME period;
char buf[BUFSIZE], data, temp;
unsigned int msg, i, len;
printf("\n\nGENERIC RECEIVE\n");
ioperm(PORT_ADR, 1, 1);
iopl(3);
if (!(spktsk = rt_task_init_schmod(nam2num("SPKTSK"), 1, 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT SPEAKER TASK\n");
exit(1);
}
rt_set_oneshot_mode();
start_rt_timer(0);
mlockall(MCL_CURRENT | MCL_FUTURE);
printf("\nSPEAKER TASK RUNNING\n");
rt_make_hard_real_time();
period = nano2count(PERIOD);
rt_task_make_periodic(spktsk, rt_get_time() + 5*period, period);
rt_returnx(rt_receivex(0, &msg, sizeof(int), &len), &msg, 1);
for (i = 0; i < 100; i++) {
rt_returnx(rt_receivex(0, &msg, sizeof(int), &len), &msg, 1);
}
len = 0;
while(1) {
if (len) {
data = filter(buf[i++]);
temp = inb(PORT_ADR);
temp &= 0xfd;
temp |= (data & 1) << 1;
outb(temp, PORT_ADR);
len--;
} else {
if (rt_evdrpx(0, buf, BUFSIZE, &i)) {
// rt_printk("EVDRP %d\n", i);
}
if ((plrtsk = rt_receivex_if(0, buf, BUFSIZE, &len))) {
rt_returnx(plrtsk, &len, sizeof(int));
if (len == sizeof(int) && ((int *)buf)[0] == 0xFFFFFFFF) {
break;
}
i = 0;
}
}
rt_task_wait_period();
}
rt_sleep(nano2count(100000000));
rt_make_soft_real_time();
stop_rt_timer();
rt_task_delete(spktsk);
printf("\nSPEAKER TASK STOPS\n");
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:60,代码来源:speaker1.c
示例11: realtime_on
int realtime_on(void){
int retval;
/*RT_TASK * rt_task_init_schmod(unsigned long name, int priority, int stack_size, int max_msg_size, int policy, int cpus_allowed)*/
if(!(task = rt_task_init_schmod(nam2num("TAREA11"), 1, 0, 0, SCHED_FIFO, 0xF))){
printf("rt_task_init_schmod error\n");
return -1;
}
mlockall( MCL_CURRENT | MCL_FUTURE );
printf("TAREAL EN TIEMPO REAL (name = %lu, address = %p)\n", nam2num("TAREA1"), task);
rt_set_oneshot_mode();
task_period_count = nano2count(task_period_ns);
timer_period_count = start_rt_timer(task_period_count);/*Inicia temporizador*/
printf("\tRequested %d counts, got %d counts\n",(int) task_period_count, (int) timer_period_count);
retval = rt_task_make_periodic(task, rt_get_time() + task_period_count, task_period_count); /* recurring period */
if (0 != retval) {
printf("rt_task_make_periodic error\n");
return -1;
}
rt_make_hard_real_time();
printf("\tPeriodo=%f\n\n",(double)task_period_ns/1e9);
return 1;
}
开发者ID:manurs,项目名称:neuron-models,代码行数:29,代码来源:realtime_manager.c
示例12: nam2num
void *signalSan(void *arg)
{
RT_TASK *Task_3;
unsigned long Task_3_name = nam2num("TSK_3") + i++;
time_t aclock;
time_t clockNow;
int timeEx, begin_3;
int count = 0;
struct tm *newtime;
Task_3 = rt_task_init(Task_3_name, 0, 0, 0);
// if(!(Task_3 = rt_task_init_schmod(Task_3_name,3,0,0,SCHED_FIFO,1))) {
// printf("CANNOT INIT HANDLER TASK > Task 3 <\n");
// exit(1);
// }
rt_allow_nonroot_hrt();
rt_make_hard_real_time();
rt_task_make_periodic(Task_3, rt_get_time(), sampling * 30);
rt_change_prio(Task_3, 3);
begin_3 = begin;
while (count < 20) {
rt_sem_wait(rMutex);
time(&aclock); // Pega tempo em segundos.
newtime = localtime(&aclock);
printf(" Signal 3 =======> %s", asctime(newtime));
sleep(1);
time(&aclock); // Pega tempo em segundos.
newtime = localtime(&aclock);
printf(" Signal 3 after Sleep =======> %s", asctime(newtime));
timeEx = 3600 * newtime->tm_hour + 60 * newtime->tm_min + newtime->tm_sec;
if( (timeEx - begin_3) > 15 )
printf(" Time Failure of the Signal 3\n");
else printf(" Time Correct of the Signal 3\n");
begin_3 = timeEx + (15 - (timeEx-begin)%15);
rt_sem_signal(rMutex);
rt_task_wait_period();
count++;
}
rt_make_soft_real_time();
rt_task_delete(Task_3);
return 0;
}
开发者ID:nosnilwar,项目名称:rtai-raw-gov-3.9.1,代码行数:60,代码来源:sample.c
示例13: printf
void *ClockChrono_Clock(void *args)
{
RT_TASK *mytask;
const int hundredthes = FALSE;
MenageHmsh_tHour hour;
MenageHmsh_tChain11 hourChain;
char command;
BOOLEAN display;
if (!(mytask = rt_thread_init(nam2num("CLOCK"), 1, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT TASK ClockChronoClock\n");
exit(1);
}
printf("INIT TASK ClockChronoClock %p.\n", mytask);
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
sem_wait(&sync_sem);
MenageHmsh_Initialise(&hour);
while(1) {
CommandClock_Get(&command);
switch(command) {
case 'R':
rt_fractionated_sleep(OneUnit);
MenageHmsh_PlusOneUnit(&hour, &display);
break;
case 'T':
MenageHmsh_InitialiseHundredthes(&hour);
display = FALSE;
break;
case 'H':
MenageHmsh_AdvanceHours(&hour);
display = TRUE;
break;
case 'M':
MenageHmsh_AdvanceMinutes(&hour);
display = TRUE;
break;
case 'S':
MenageHmsh_AdvanceSeconds(&hour);
display = TRUE;
break;
case 'F':
goto end;
}
if (display) {
MenageHmsh_Convert(hour, hundredthes, &hourChain);
Display_PutHour(hourChain);
}
}
end:
rt_make_soft_real_time();
hourChain.chain[1] = 'e';
Display_PutHour(hourChain);
rt_task_delete(mytask);
printf("END TASK ClockChronoClock %p.\n", mytask);
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:58,代码来源:clock.c
示例14: main
int main(int argc, char *argv[])
{
unsigned int player, msg, spknode, spkport, i;
RT_TASK *plrtsk, *spktsk;
struct sockaddr_in addr;
char data[BUFSIZE];
thread = rt_thread_create(endme, NULL, 2000);
if ((player = open("../../../share/linux.au", O_RDONLY)) < 0) {
printf("ERROR OPENING SOUND FILE (linux.au)\n");
exit(1);
}
if (!(plrtsk = rt_task_init_schmod(nam2num("PLRTSK"), 2, 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT PLAYER TASK\n");
exit(1);
}
spknode = 0;
if (argc == 2 && strstr(argv[1], "SpkNode=")) {
inet_aton(argv[1] + 8, &addr.sin_addr);
spknode = addr.sin_addr.s_addr;
}
if (!spknode) {
inet_aton("127.0.0.1", &addr.sin_addr);
spknode = addr.sin_addr.s_addr;
}
while ((spkport = rt_request_hard_port(spknode)) <= 0 && spkport != -EINVAL);
rt_make_hard_real_time();
spktsk = RT_get_adr(spknode, spkport, "SPKTSK");
RT_rpcx(spknode, spkport, spktsk, &i, &msg, sizeof(int), sizeof(int));
for (i = 0; i < 100; i++) {
RT_rpcx(spknode, spkport, spktsk, &i, &msg, sizeof(int), sizeof(int));
}
mlockall(MCL_CURRENT | MCL_FUTURE);
printf("\nPLAYER TASK RUNNING\n(TYPE ENTER TO END EVERYTHING)\n");
while (!end) {
lseek(player, 0, SEEK_SET);
while(!end && (i = read(player, data, BUFSIZE)) > 0) {
RT_rpcx(spknode, spkport, spktsk, data, &msg, i, sizeof(int));
if (msg != i) {
printf("SPEAKER RECEIVED LESS THAN SENT BY PLAYER\n");
}
}
}
msg = 0xFFFFFFFF;
RT_rpcx(spknode, spkport, spktsk, &msg, &msg, sizeof(int), 1);
rt_make_soft_real_time();
rt_release_port(spknode, spkport);
rt_task_delete(plrtsk);
close(player);
printf("PLAYER TASK STOPS\n");
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:58,代码来源:player.c
示例15: main
int main(void)
{
double omega = (2.0*M_PI*SIN_FREQ*SAMP_TIME)/1.0E9;
RTIME until;
RT_TASK *task;
lsampl_t data[NCHAN*2];
long k, sinewave, retval = 0;
signal(SIGKILL, endme);
signal(SIGTERM, endme);
start_rt_timer(0);
task = rt_task_init_schmod(nam2num("MYTASK"), 1, 0, 0, SCHED_FIFO, 0xF);
printf("COMEDI CMD TEST BEGINS: SAMPLING FREQ: %d, RUN TIME: %d.\n", SAMP_FREQ, RUN_TIME);
if (init_board()) {;
printf("Board initialization failed.\n");
return 1;
}
do_cmd();
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
until = rt_get_cpu_time_ns() + (long long)RUN_TIME*1000000000;
for (k = 0; k < SAMP_FREQ*RUN_TIME && !end; k++) {
sinewave = (long)(maxdata/4*sin(k*omega));
data[0] = (lsampl_t)( sinewave + maxdata/2);
data[1] = (lsampl_t)(- sinewave + maxdata/2);
while (rt_comedi_command_data_write(dev, subdev, NCHAN, data) != NCHAN) {
rt_sleep(nano2count(SAMP_TIME/2));
}
if (k == TRIGSAMP) {
rt_comedi_trigger(dev, subdev);
}
}
while (until > rt_get_cpu_time_ns()) {
rt_sleep(nano2count(100000));
}
comedi_cancel(dev, subdev);
comedi_close(dev);
comedi_data_write(dev, subdev, 0, 0, AREF_GROUND, 2048);
comedi_data_write(dev, subdev, 1, 0, AREF_GROUND, 2048);
printf("COMEDI TEST ENDS.\n");
if (retval < 0) {
printf("rt_comedi_wait_timed overruns: %d\n", abs(retval));
}
stop_rt_timer();
rt_make_soft_real_time();
rt_task_delete(task);
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:57,代码来源:aocmd.c
示例16: taskname
void *thread_fun(void *arg)
{
RTIME start_time, period;
RTIME t0, t;
SEM *sem;
RT_TASK *mytask;
unsigned long mytask_name;
int mytask_indx, jit, maxj, maxjp, count;
mytask_indx = *((int *)arg);
mytask_name = taskname(mytask_indx);
cpus_allowed = 1 - cpus_allowed;
if (!(mytask = rt_task_init_schmod(mytask_name, 1, 0, 0, SCHED_FIFO, 1 << cpus_allowed))) {
printf("CANNOT INIT TASK %lu\n", mytask_name);
exit(1);
}
printf("THREAD INIT: index = %d, name = %lu, address = %p.\n", mytask_indx, mytask_name, mytask);
mlockall(MCL_CURRENT | MCL_FUTURE);
if (!(mytask_indx%2)) {
rt_make_hard_real_time();
}
rt_receive(0, (unsigned long *)((void *)&sem));
period = nano2count(PERIOD);
start_time = rt_get_time() + nano2count(10000000);
rt_task_make_periodic(mytask, start_time + (mytask_indx + 1)*period, ntasks*period);
// start of task body
{
count = maxj = 0;
t0 = rt_get_cpu_time_ns();
while(count++ < LOOPS) {
rt_task_wait_period();
t = rt_get_cpu_time_ns();
if ((jit = t - t0 - ntasks*(RTIME)PERIOD) < 0) {
jit = -jit;
}
if (count > 1 && jit > maxj) {
maxj = jit;
}
t0 = t;
// rtai_print_to_screen("THREAD: index = %d, count %d\n", mytask_indx, count);
}
maxjp = (maxj + 499)/1000;
}
// end of task body
rt_sem_signal(sem);
if (!(mytask_indx%2)) {
rt_make_soft_real_time();
}
rt_task_delete(mytask);
printf("THREAD %lu ENDS, LOOPS: %d MAX JIT: %d (us)\n", mytask_name, count, maxjp);
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:57,代码来源:threaded.c
示例17: main
int main(int argc, char *argv[])
{
unsigned long msg;
int prio, bprio;
if (argc > 1) {
USE_RPC = atoi(argv[1]);
SNDBRCV = atoi(argv[2]);
HARDMAIN = atoi(argv[3]);
}
if (!(maintask = rt_task_init_schmod(0xcacca, 1, 0, 0, SCHED_FIFO, 0x1))) {
rt_printk("CANNOT INIT MAIN\n");
exit(1);
}
start_rt_timer(0);
rt_printk("MAIN INIT\n");
pthread_create(&thread, NULL, thread_fun, NULL);
mlockall(MCL_CURRENT | MCL_FUTURE);
if (HARDMAIN) {
rt_make_hard_real_time();
}
rt_get_priorities(maintask, &prio, &bprio);
rt_printk("TEST: %s, %s, %d\n", USE_RPC ? "WITH RPC" : "WITH SUSP/RESM", SNDBRCV ? "SEND BEFORE RECEIVE" : "RECEIVE BEFORE SEND", prio);
if (SNDBRCV) {
rt_sleep(nano2count(100000000));
}
rt_get_priorities(maintask, &prio, &bprio);
rt_printk("MAIN REC %d\n", prio);
if (USE_RPC) {
RT_TASK *task;
task = rt_receive(0, &msg);
rt_get_priorities(maintask, &prio, &bprio);
rt_printk("MAIN RET %d\n", prio);
rt_return(task, 0);
} else {
rt_receive(0, &msg);
rt_get_priorities(maintask, &prio, &bprio);
rt_printk("MAIN RES %d\n", prio);
rt_task_resume(funtask);
}
rt_get_priorities(maintask, &prio, &bprio);
rt_printk("MAIN DONE %d\n", prio);
stop_rt_timer();
rt_task_delete(maintask);
rt_printk("MAIN END\n");
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:54,代码来源:inhermsg.c
示例18: PRINTF
void *ThreadImplLxrt35::runThread(void *arg)
{
ThreadImplLxrt35 *self = static_cast<ThreadImplLxrt35*>(arg);
if (self->m_rt_start_sync == NULL)
{
// Technically, this can never happen because this condition is
// already checked in the Start() function. But who knows!
PRINTF("ERROR: NULL thread start barrier!\n");
}
else
{
self->m_rt_task = rt_task_init(getpid() + pthread_self_rt(), abs(self->m_priority),
DEFAULT_STACK_SIZE, 0);
if (self->m_rt_task == NULL)
{
PRINTF("ERROR: Cannot initialize LXRT task %lu!\n", self->m_thread_id);
PRINTF(" Probably another thread with the same name already exists.\n");
// Let the thread, which started us, continue!
pthread_barrier_wait_rt(self->m_rt_start_sync);
}
else
{
if (self->m_priority < 0)
{
rt_make_hard_real_time();
if (!rt_is_hard_real_time(rt_buddy()))
{
PRINTF("ERROR: Setting thread %lu to hard real-time failed!\n", self->m_thread_id);
}
else
{
// Everything worked as expected, so no message here.
}
}
else
{
// This is a soft realtime thread, so nothing additional has
// to be done here.
}
pthread_barrier_wait_rt(self->m_rt_start_sync);
self->m_thread->runThread();
// Remark: It does not hurt to call this in a soft realtime
// thread, so just skip the hard realtime test.
rt_make_soft_real_time();
}
}
return NULL;
}
开发者ID:HumaRobotics,项目名称:fzi_icl_core,代码行数:54,代码来源:ThreadImplLxrt35.cpp
示例19: main
int main(void)
{
RT_TASK *spktsk, *plrtsk;
RTIME period;
MBX *mbx;
char data, temp;
unsigned int msg, i;
// ioperm(PORT_ADR, 1, 1);
iopl(3);
if (!(spktsk = rt_task_init_schmod(nam2num("SPKTSK"), 1, 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT SPEAKER TASK\n");
exit(1);
}
mbx = rt_mbx_init(nam2num("SNDMBX"), 4000);
printf("\nSPEAKER TASK RUNNING\n");
rt_set_oneshot_mode();
start_rt_timer(0);
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
period = nano2count(PERIOD);
rt_task_make_periodic(spktsk, rt_get_time() + 5*period, period);
for (i = 0; i < 100; i++) {
plrtsk = rt_receive(0, &msg);
rt_return(plrtsk, msg);
}
while(1) {
if (!rt_mbx_receive_if(mbx, &data, 1)) {
data = filter(data);
temp = inb(PORT_ADR);
temp &= 0xfd;
temp |= (data & 1) << 1;
outb(temp, PORT_ADR);
}
rt_task_wait_period();
if ((plrtsk = rt_receive_if(0, &msg))) {
rt_return(plrtsk, msg);
break;
}
}
rt_sleep(nano2count(100000000));
rt_make_soft_real_time();
rt_mbx_delete(mbx);
stop_rt_timer();
rt_task_delete(spktsk);
printf("\nSPEAKER TASK STOPS\n");
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:53,代码来源:speaker.c
示例20: rtos_task_set_scheduler
INTERNAL_QUAL int rtos_task_set_scheduler(RTOS_TASK* t, int s) {
if ( t->rtaitask == 0 || t->rtaitask != rt_buddy() ) {
return -1;
}
if (rtos_task_check_scheduler(&s) == -1)
return -1;
if (s == SCHED_LXRT_HARD)
rt_make_hard_real_time();
else if ( s == SCHED_LXRT_SOFT)
rt_make_soft_real_time();
return 0;
}
开发者ID:pelletierts,项目名称:orocos-rtt,代码行数:12,代码来源:fosi_internal.cpp
注:本文中的rt_make_hard_real_time函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论