本文整理汇总了C++中rt_make_soft_real_time函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_make_soft_real_time函数的具体用法?C++ rt_make_soft_real_time怎么用?C++ rt_make_soft_real_time使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_make_soft_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: main
int main(void)
{
int i, srq, count = 0, nextcount = 0, repeat;
rt_thread_init(nam2num("MNTSK"), 100, 0, SCHED_FIFO, 0x1);
rt_printk("\nTESTING THE SCHEDULER WITH SRQs [%d LOOPs].\n", LOOPS);
repeat = 1000000000LL/((long long)DELAY*(long long)PRINT_FREQ);
srq = rtai_open_srq(0xcacca);
start_rt_timer(0);
rt_grow_and_lock_stack(100000);
#ifdef MAKE_HARD
MAKE_HARD();
#endif
for (i = 0; i < LOOPS; i++) {
rtai_srq(srq, (unsigned long)nano2count(DELAY));
if (++count > nextcount) {
nextcount += repeat;
rt_printk(">>> %d.\n", nextcount);
}
}
rt_make_soft_real_time();
stop_rt_timer();
rt_task_delete(NULL);
rt_printk("END SCHEDULER TEST WITH SRQs.\n\n");
return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:28,代码来源:display.c
示例3: 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
示例4: 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
示例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: 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
示例7: 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
示例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: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: delete_tasks
void delete_tasks(void)
{
rt_make_soft_real_time();
rt_task_delete(Task_1);
rt_task_delete(Task_2);
rt_task_delete(Task_3);
rt_task_delete(Task_4);
printf("\nFim do Escalonamento\n");
}
开发者ID:nosnilwar,项目名称:rtai-raw-gov-3.9.1,代码行数:11,代码来源:multiple_tasks.c
示例15: 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
示例16: sprintf
static void *rt_BaseRate(void *args)
{
char name[7];
int i;
static RTIME t0;
for (i = 0; i < MAX_NTARGETS; i++) {
sprintf(name,"BRT%d",i);
if (!rt_get_adr(nam2num(name))) break;
}
if (!(rt_BaseRateTask = rt_task_init_schmod(nam2num(name), *((int *)args), 0, 0, SCHED_FIFO, CpuMap))) {
fprintf(stderr,"Cannot init rt_BaseRateTask.\n");
return (void *)1;
}
sem_post(&err_sem);
iopl(3);
rt_task_use_fpu(rt_BaseRateTask, 1);
MXmain();
grow_and_lock_stack(stackinc);
if (UseHRT) {
rt_make_hard_real_time();
}
rt_rpc(rt_MainTask, 0, (void *)name);
t0 = rt_get_cpu_time_ns();
rt_task_make_periodic(rt_BaseRateTask, rt_get_time() + rt_BaseRateTick, rt_BaseRateTick);
while (!endBaseRate) {
#ifdef TASKDURATION
RTTSKper=rt_get_cpu_time_ns()-RTTSKinit;
#endif
WaitTimingEvent(TimingEventArg);
if (endBaseRate) break;
APPLICATION_Process_Event(TIME_EV);
SIM_TIME = (rt_get_cpu_time_ns() - t0)*1.0E-9;
#ifdef TASKDURATION
RTTSKinit=rt_get_cpu_time_ns();
#endif
}
if (UseHRT) {
rt_make_soft_real_time();
}
rt_task_delete(rt_BaseRateTask);
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:53,代码来源:rtmain.c
示例17: 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
示例18: 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
示例19: main
int main(int argc, char *argv[])
{
unsigned long rcvnode;
RT_TASK *sndtsk, *rcvtsk;
MBX *mbx;
long rcvport, i;
struct sockaddr_in addr;
thread = rt_thread_create(endme, NULL, 2000);
if (!(sndtsk = rt_task_init_schmod(nam2num("SNDTSK"), 1, 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT SENDER TASK\n");
exit(1);
}
rcvnode = 0;
if (argc == 2 && strstr(argv[1], "RcvNode=")) {
inet_aton(argv[1] + 8, &addr.sin_addr);
rcvnode = addr.sin_addr.s_addr;
}
if (!rcvnode) {
inet_aton("127.0.0.1", &addr.sin_addr);
rcvnode = addr.sin_addr.s_addr;
}
mbx = rt_mbx_init(nam2num("SNDMBX"), 500);
while ((rcvport = rt_request_port(rcvnode)) <= 0 && rcvport != -EINVAL);
printf("\nSENDER TASK RUNNING\n");
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_make_hard_real_time();
for (i = 0; i < MAXLOOPS && !end; i++) {
rt_mbx_send(mbx, &i, sizeof(long));
rt_printk("SENT %ld\n", i);
RT_sleep(rcvnode, rcvport, 200000000);
}
i = -1;
rt_mbx_send(mbx, &i, sizeof(long));
rt_make_soft_real_time();
while (!(rcvtsk = RT_get_adr(rcvnode, rcvport, "RCVTSK"))) {
RT_sleep(rcvnode, rcvport, 100000000);
}
RT_rpc(rcvnode, rcvport, rcvtsk, i, &i);
rt_release_port(rcvnode, rcvport);
rt_mbx_delete(mbx);
rt_task_delete(sndtsk);
printf("\nSENDER TASK STOPS\n");
return 0;
}
开发者ID:ArcEye,项目名称:RTAI,代码行数:48,代码来源:sender.c
示例20: pthread_setcanceltype
static void *intr_handler(void *args)
{
RT_TASK *mytask, *master;
RTIME period;
MBX *mbx;
char data = 'G';
char temp;
unsigned int msg;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
// rt_allow_nonroot_hrt();
ioperm(PORT_ADR, 1, 1);
if (!(mytask = rt_task_init_schmod(nam2num("SOUND"), 1, 0, 0, SCHED_FIFO, 0xF))) {
printf("CANNOT INIT SOUND TASK\n");
exit(1);
}
mbx = rt_get_adr(nam2num("SNDMBX"));
mlockall(MCL_CURRENT | MCL_FUTURE);
printf("\nINIT SOUND TASK %p\n", mytask);
rt_make_hard_real_time();
period = nano2count(PERIOD);
rt_mbx_send(mbx, &data, 1);
rt_task_make_periodic(mytask, rt_get_time() + 100*period, period);
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 ((master = rt_receive_if(0, &msg))) {
rt_return(master, msg);
break;
}
}
rt_make_soft_real_time();
rt_task_delete(mytask);
printf("\nEND SOUND TASK %p\n", mytask);
return 0;
}
开发者ID:sensysnetworks,项目名称:stromboli-24.1,代码行数:47,代码来源:rt_process.c
注:本文中的rt_make_soft_real_time函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论