本文整理汇总了C++中rt_task_start函数的典型用法代码示例。如果您正苦于以下问题:C++ rt_task_start函数的具体用法?C++ rt_task_start怎么用?C++ rt_task_start使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rt_task_start函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(){
rt_print_auto_init(1);
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_task_shadow(NULL, "main", 5, T_CPU(0)|T_JOINABLE);
#ifdef mutex
rt_mutex_create(&a, "Mutex");
rt_mutex_create(&b, "b");
#endif
rt_task_create(&task1, "Task1", 0, 1, T_CPU(0)|T_JOINABLE);
rt_task_create(&task2, "Task2", 0, 2, T_CPU(0)|T_JOINABLE);
rt_task_start(&task1, &semWait1, NULL);
rt_task_start(&task2, &semWait2, NULL);
rt_printf("sync \n");
rt_task_join(&task1);
rt_task_join(&task2);
#ifdef mutex
rt_mutex_delete(&a);
rt_mutex_delete(&b);
#endif
}
示例2: startup
//startup code
void startup(){
int err = 0;
// semaphore to sync task startup on
err = rt_sem_create(&mysync,"MySemaphore",1,S_FIFO);
if(err < 0) rt_printf("Failed to create semaphore; error: %d: %s", err, strerror(-err));
err = 0;
// set timing to ns
rt_timer_set_mode(BASEPERIOD);
err = rt_task_create(&highP, "high", 0, HIGH, 0);
if(err < 0) rt_printf("Failed to create task high; error: %d: %s", err, strerror(-err));
err = 0;
err = rt_task_start(&highP, &prioHigh, 0);
if(err < 0) rt_printf("Failed to start task high; error: %d: %s", err, strerror(-err));
err = 0;
err = rt_task_create(&midP, "mid", 0, MID, 0);
if(err < 0) rt_printf("Failed to create task medium; error: %d: %s", err, strerror(-err));
err = 0;
err = rt_task_start(&midP, &prioMid, 0);
if(err < 0) rt_printf("Failed to start task medium; error: %d: %s", err, strerror(-err));
err = 0;
err = rt_task_create(&lowP, "low", 0, LOW, 0);
if(err < 0) rt_printf("Failed to create task low; error: %d: %s", err, strerror(-err));
err = 0;
err = rt_task_start(&lowP, &prioLow, 0);
if(err < 0) rt_printf("Failed to start task low; error: %d: %s", err, strerror(-err));
err = 0;
}
示例3: main
int main(){
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_print_auto_init(1);
rt_sem_create(&semaphore, "sem", 1, S_PRIO);
rt_sem_create(&synca, "sync", 0, S_PRIO);
rt_mutex_create(&mutex, "mutex");
RT_TASK L, M, H;
rt_task_shadow(NULL, "main", 4, T_CPU(1)|T_JOINABLE);
rt_task_create(&L, "low", 0, 1, T_CPU(1)|T_JOINABLE);
rt_task_create(&M, "medium", 0, 2, T_CPU(1)|T_JOINABLE);
rt_task_create(&H, "high", 0, 3, T_CPU(1)|T_JOINABLE);
rt_task_start(&L, &low, (void*) 0);
rt_task_start(&M, &medium, (void*) 0);
rt_task_start(&H, &high, (void*) 0);
usleep(100000);
rt_printf("RELEASING SYNC\n");
rt_sem_broadcast(&synca);
rt_task_join(&L);
rt_task_join(&M);
rt_task_join(&H);
rt_sem_delete(&synca);
rt_sem_delete(&semaphore);
rt_mutex_delete(&mutex);
return 0;
}
示例4: main
int main() {
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_print_auto_init(1);
RT_TASK low, med, high, sync;
rt_task_create(&low, "low", 0, 10, T_CPU(1)|T_JOINABLE);
rt_task_create(&med, "med", 0, 20, T_CPU(1)|T_JOINABLE);
rt_task_create(&high, "high", 0, 30, T_CPU(1)|T_JOINABLE);
rt_task_create(&sync, "sync", 0, 99, T_CPU(1)|T_JOINABLE);
rt_sem_create(&sem, "sem", 0, S_PRIO);
rt_sem_create(&resourceSem, "resourceSem", 1, S_PRIO);
rt_mutex_create(&resourceMutex, "resourceMutex");
rt_task_start(&low, &lowFunc, NULL);
rt_task_start(&med, &medFunc, NULL);
rt_task_start(&high, &highFunc, NULL);
rt_task_start(&sync, &syncFunc, NULL);
rt_task_join(&low);
rt_task_join(&med);
rt_task_join(&high);
rt_task_join(&sync);
rt_sem_delete(&sem);
rt_sem_delete(&resourceSem);
rt_mutex_delete(&resourceMutex);
return 0;
}
示例5: main
int main(int argc, char* argv[])
{
signal(SIGTERM, catch_signal);
//signal(SIGINT, catch_signal);
int statusA, statusG, statusF, mutexacc, mutexgyro, i,j;
logIndex = 0;
// enable rt_task_print
rt_print_auto_init(1);
/* Avoids memory swapping for this program */
mlockall(MCL_CURRENT|MCL_FUTURE);
// Create mutexs
mutexgyro = rt_mutex_create(&mutex_gyro,NULL);
if(mutexgyro!=0){
fprintf(stderr, "Unable to create gyroscope mutex! Exiting...\n");
exit(EXIT_FAILURE);
}
mutexacc = rt_mutex_create(&mutex_acc,NULL);
if(mutexacc!=0){
fprintf(stderr, "Unable to create accelorometer mutex! Exiting...\n");
exit(EXIT_FAILURE);
}
isRunning = 1;
/*
* Arguments: &task, name, stack size (0=default), priority,
* mode (FPU, start suspended, ...)
*/
statusA = rt_task_create(&accThread, NULL, 0, 0, T_JOINABLE);
statusG = rt_task_create(&gyroThread, NULL, 0, 0, T_JOINABLE);
statusF = rt_task_create(&fusThread, NULL, 0, 0, T_JOINABLE);
/*
* Arguments: &task, task function, function argument
*/
statusA = rt_task_start(&accThread, &accelerometer, NULL);
statusG = rt_task_start(&gyroThread, &gyroscope, NULL);
statusF = rt_task_start(&fusThread, &sensor_fusion, NULL);
// threads in infinite loop, therefore this prevents the main from finishing
// (and killing its threads)
statusA = rt_task_join(&gyroThread);
statusF = rt_task_join(&fusThread);
statusG = rt_task_join(&accThread);
printlog[logIndex] = 4000;
for (i = 0; i < 50; i++) {
printf("Fusion%d: %d\n", i, printlog[i]);
}
rt_mutex_delete(&mutex_acc);
rt_mutex_delete(&mutex_gyro);
}
示例6: main
int main(int argc, char* argv[])
{
// Perform auto-init of rt_print buffers if the task doesn't do so
rt_print_auto_init(1);
// Lock memory : avoid memory swapping for this program
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_printf("starting tasks\n");
/*
* Arguments: &task,
* name,
* stack size (0=default),
* priority,
* mode (FPU, start suspended, ...)
*/
rt_task_create(&task1, "t1", 0, 50, 0);
rt_task_create(&task2, "t2", 0, 50, 0);
rt_task_create(&task3, "t3", 0, 50, 0);
rt_task_create(&task4, "t4", 0, 50, 0);
rt_task_create(&task5, "t5", 0, 50, 0);
/*
* Arguments: &task,
* task function,
* function argument
*/
rt_task_start(&task1, &task, 0);
rt_task_start(&task2, &task, 0);
rt_task_start(&task3, &task, 0);
rt_task_start(&task4, &task, 0);
rt_task_start(&task5, &task, 0);
}
示例7: startup
void startup(){
rt_queue_create(&rqueue, "rQueue", QUEUE_SIZE, 40, Q_FIFO);
rt_queue_create(&lqueue, "lQueue", QUEUE_SIZE, 40, Q_FIFO);
//rt_sem_create(&rsem, "rsem", 0, S_FIFO);
//&task, name, stack size (0 - default), priority, mode
rt_task_create(&rEnc_task, "rEnc Task", 0, 50, 0);
//&task, task function, function argument
rt_task_start(&rEnc_task, &rEnc, 0);
//&task, name, stack size (0 - default), priority, mode
rt_task_create(&lEnc_task, "lEnc Task", 0, 50, 0);
//&task, task function, function argument
rt_task_start(&lEnc_task, &lEnc, 0);
//&task, name, stack size (0 - default), priority, mode
rt_task_create(&Odo_task, "Odo Task", 0, 60, 0);
//&task, task function, function argument
rt_task_start(&Odo_task, &Odo, 0);
//rt_sem_broadcast(&rsem);
}
示例8: main
int main(int argc, char *const argv[])
{
int ret;
traceobj_init(&trobj, argv[0], 0);
ret = rt_sem_create(&sem, "SEMA", 0, S_FIFO);
traceobj_check(&trobj, ret, 0);
ret = rt_task_create(&t_rr1, "rr_task_1", 0, 10, 0);
traceobj_check(&trobj, ret, 0);
ret = rt_task_start(&t_rr1, rr_task, "t1");
traceobj_check(&trobj, ret, 0);
ret = rt_task_create(&t_rr2, "rr_task_2", 0, 10, 0);
traceobj_check(&trobj, ret, 0);
ret = rt_task_start(&t_rr2, rr_task, "t2");
traceobj_check(&trobj, ret, 0);
ret = rt_sem_broadcast(&sem);
traceobj_check(&trobj, ret, 0);
traceobj_join(&trobj);
exit(0);
}
示例9: main
int main(int argc, char* argv[])
{
// Perform auto-init of rt_print buffers if the task doesn't do so
rt_print_auto_init(1);
// Lock memory : avoid memory swapping for this program
mlockall(MCL_CURRENT|MCL_FUTURE);
rt_printf("starting tasks\n");
int res = rt_sem_create(&semGlobal, "a", 0, S_PRIO);
if(res < 0) rt_printf("Failed to create semaphore; error: %d: %s", res, strerror(-res));
rt_task_create(&task1, "t1", 0, 10, 0);
rt_task_create(&task2, "t2", 0, 20, 0);
rt_task_create(&task3, "t3", 0, 30, 0);
rt_task_create(&task4, "t4", 0, 40, 0);
rt_task_create(&task5, "t5", 0, 50, 0);
int a1 = 1;
int a2 = 2;
int a3 = 3;
int a4 = 4;
int a5 = 5;
rt_task_start(&task1, &task, &a1);
rt_task_start(&task2, &task, &a2);
rt_task_start(&task3, &task, &a3);
rt_task_start(&task4, &task, &a4);
rt_task_start(&task5, &task, &a5);
rt_sem_broadcast(&semGlobal);
}
示例10: startup
//startup code
void startup()
{
rt_intr_create(&keypress, NULL, KEYBOARD_IRQ, I_PROPAGATE);
rt_task_create(&key_isr, NULL,0,50,0);
rt_task_start(&key_isr, &key_handler, NULL);
// Higher priority
rt_task_create(&dummy, NULL,0,53,0);
rt_task_start(&dummy, &dummy_task, NULL);
}
示例11: startup
void startup(){
// rt_task_create(&rMotor_task, "rMotor Task", 0, 50, 0);
// rt_task_create(&lMotor_task, "lMotor Task", 0, 50, 0);
//rt_task_create(&rMotor_stop_task, "rMotor Stop Task", 0, 51, 0);
//rt_task_create(&lMotor_stop_task, "lMotor Stop Task", 0, 51, 0);
rt_task_create(&rMotor_task, "rMotor Task", 0, 50, 0);
rt_task_create(&lMotor_task, "lMotor Task", 0, 50, 0);
// rt_task_start(&rMotor_stop_task, &rMotor_stop, 0);
//rt_task_start(&lMotor_stop_task, &lMotor_stop, 0);
rt_task_start(&rMotor_task, &rMotor, 0);
rt_task_start(&lMotor_task, &lMotor, 0);
}
示例12: mlockall
RealtimeController::RealtimeController()
{
// lukitaan ohjelman nykyinen ja tuleva muisti niin että se pysyy RAM:ssa kokoajan
mlockall(MCL_CURRENT | MCL_FUTURE);
int xenoError = 0;
// luodaan task-handle reaaliaikasäikeelle
// antamalla T_FPU | T_JOINABLE saattaisi olla mahdollista käyttää
// mittausarvoja doubleina Voltteina koko ohjelmassa
xenoError = rt_task_create(&task_desc, NULL, 0, 99, T_JOINABLE);
xenoError = rt_pipe_create(&pipe_desc, NULL, 0, 0);
if(xenoError != 0)
qDebug("rt init error");
// käynnistetään säie
rt_task_start(&task_desc, &realtimeLoop, NULL);
// luodaan pipe reaaliaikasäikeen kanssa kommunikointiin
pipefd = open("/dev/rtp0", O_RDWR, 0);
if (pipefd < 0)
qDebug("Creating pipe failed");
// pysäytetään säätö oletuksena
stop();
}
示例13: while
bool RTROSMotorSettingService::motorSet(rt_dynamixel_msgs::MotorSettingRequest &req,
rt_dynamixel_msgs::MotorSettingResponse &res)
{
for(int i=0; i<4; i++)
{
dxlDevice[i].bControlLoopEnable = false;
}
for(int i=0; i<4; i++)
{
while(dxlDevice[i].bControlLoopProcessing) {}
}
RT_TASK rttMotorSetTask;
rt_task_create(&rttMotorSetTask,"dxl motorset service",0,7,T_JOINABLE);
motorResponse.result = -1;
motorRequest = req;
rt_task_start(&rttMotorSetTask, &motor_set_proc, (void*)this);
rt_task_join(&rttMotorSetTask);
rt_task_delete(&rttMotorSetTask);
res = motorResponse;
//res.result = req.mode;
for(int i=0; i<4; i++)
{
dxlDevice[i].bControlLoopEnable = true;
}
return true;
}
示例14: assignmentA
void assignmentA(int period_us, int ndisturbance)
{
printf("Starting Assignment A!\n");
period_ns = period_us * 1000;
RT_TASK rt[N_RT];
pthread_t ts[ndisturbance];
char *names[N_RT] = { "thread_a", "thread_b", "thread_c" };
int channels[N_RT] = { CHANNEL_A, CHANNEL_B, CHANNEL_C };
mlockall(MCL_CURRENT | MCL_FUTURE);
int i;
for (i = 0; i < ndisturbance; i++)
{
pthread_create(&ts[i], 0, disturbanceInTheForce, NULL);
}
for (i = 0; i < N_RT; i++)
{
rt_task_create(&rt[i], names[i], 0, 99, 0);
rt_task_start(&rt[i], responseHandlerPeriodic, &channels[i]);
}
while (1);
}
示例15: main
int main (int argc, char *argv[])
{
static char *messages[] = { "hello", "world", NULL };
int n, len;
void *msg;
mlockall(MCL_CURRENT|MCL_FUTURE);
err = rt_task_create(&task_desc,
"MyTaskName",
TASK_STKSZ,
TASK_PRIO,
TASK_MODE);
if (!err)
rt_task_start(&task_desc,&task_body,NULL);
/* ... */
for (n = 0; messages[n] != NULL; n++)
{
len = strlen(messages[n]) + 1;
/* Get a message block of the right size. */
msg = rt_queue_alloc(&q_desc,len);
if (!msg)
/* No memory available. */
fail();
strcpy(msg,messages[n]);
rt_queue_send(&q_desc,msg,len,Q_NORMAL);
}
rt_task_delete(&task_desc);
}