本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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();
}
}
示例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);
}
示例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
}
示例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");
}
示例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;
}
示例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;
}
示例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;
}
示例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"); }
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}