* [Xenomai-help] another question
@ 2006-03-14 10:47 marcellin
2006-03-14 11:46 ` Jan Kiszka
0 siblings, 1 reply; 2+ messages in thread
From: marcellin @ 2006-03-14 10:47 UTC (permalink / raw)
To: xenomai
Sorry, but with this tiny program i have the same error : Operation not
permitted. What is wrong ?
#include <sys/mman.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <getopt.h>
#include <time.h>
#include <native/task.h>
#include <native/mutex.h>
#include <native/timer.h>
#include <native/sem.h>
#include <native/intr.h>
#include <native/cond.h>
#include <rtdm/rtbenchmark.h>
#include <linux/rtc.h>
#include <sys/ioctl.h>
//#include <sys/time.h>
//#include <sys/types.h>
#include <fcntl.h>
#include <errno.h>
RT_TASK task;
RT_INTR intr_desc;
RT_COND cond;
RT_MUTEX mutextest;
int err;
void mytask(void * cookie)
{
sleep(1);
err = rt_cond_signal(&cond);
if(err != 0){
printf("\nrt_cond_signal : %s",strerror(-err));
}
}
int main (int argc, char **argv)
{
mlockall(MCL_CURRENT | MCL_FUTURE);
rt_timer_set_mode(TM_ONESHOT);
err = rt_cond_create(&cond,"condition");
if(err != 0){
printf("\nrt_cond_create : %s",strerror(-err));
}
err = rt_mutex_create(&mutextest,"mut");
if(err != 0){
printf("\nrt_mutex_create : %s",strerror(-err));
}
err = rt_task_create(&task,"SecondTask",0,99,0);
if(err != 0){
printf("\nrt_task_create : %s",strerror(-err));
}
err = rt_task_start(&task,&mytask,NULL);
if(err != 0){
printf("\nrt_task_start : %s",strerror(-err));
}
err = rt_cond_wait(&cond,&mutextest,TM_INFINITE);
if(err != 0){
printf("\nrt_cond_wait : %s",strerror(-err));
}
printf("\nend \n");
retrurn(0);
}
regards
Marcell1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Xenomai-help] another question
2006-03-14 10:47 [Xenomai-help] another question marcellin
@ 2006-03-14 11:46 ` Jan Kiszka
0 siblings, 0 replies; 2+ messages in thread
From: Jan Kiszka @ 2006-03-14 11:46 UTC (permalink / raw)
To: marcellin; +Cc: xenomai
[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]
marcellin wrote:
> Sorry, but with this tiny program i have the same error : Operation not
> permitted. What is wrong ?
>
> ...
> int main (int argc, char **argv)
> {
>
> mlockall(MCL_CURRENT | MCL_FUTURE);
> rt_timer_set_mode(TM_ONESHOT);
>
> err = rt_cond_create(&cond,"condition");
> if(err != 0){
> printf("\nrt_cond_create : %s",strerror(-err));
> }
> err = rt_mutex_create(&mutextest,"mut");
> if(err != 0){
> printf("\nrt_mutex_create : %s",strerror(-err));
> }
>
> err = rt_task_create(&task,"SecondTask",0,99,0);
> if(err != 0){
> printf("\nrt_task_create : %s",strerror(-err));
> }
> err = rt_task_start(&task,&mytask,NULL);
> if(err != 0){
> printf("\nrt_task_start : %s",strerror(-err));
> }
>
>
> err = rt_cond_wait(&cond,&mutextest,TM_INFINITE);
You have to map your main thread to a native thread before you can
invoke a blocking RT service. Check rt_task_shadow() (and don't forget
to clean it up on exit).
> if(err != 0){
> printf("\nrt_cond_wait : %s",strerror(-err));
> }
> printf("\nend \n");
>
> retrurn(0);
>
> }
>
> regards
>
> Marcell1
>
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-14 11:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-14 10:47 [Xenomai-help] another question marcellin
2006-03-14 11:46 ` Jan Kiszka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.