Thorsten Pohlmann (GERMANY)
Message: 103463
#include "stdio.h"
#include <unistd.h>
#include <sys/mman.h>
#include <rtdm/rtdm.h>
#include <native/task.h>
#include <native/timer.h>
#include <native/event.h>
#include <native/intr.h>
#include <stdlib.h>
static RT_TASK task1, task2;
static RT_EVENT event __attribute__ ((l1_data));
static void th1(void* p) __attribute__ ((l1_text));
static void th1(void* p)
{
RT_EVENT ev;
int ret = rt_event_bind(&ev,"at_evt",TM_NONBLOCK);
if(ret)
{
printf("bind at_evt failed: %s\r\n",strerror(-ret));
exit(1);
}
unsigned long ix;
do
{
int e = rt_event_wait(&ev,(unsigned long)-1,&ix,EV_ANY,TM_INFINITE);
if(e)
{
printf("at_evt failed: %s\r\n",strerror(-e));
}
ix = 0;
rt_event_clear(&ev,(unsigned long)-1,0L);
printf("evt\r\n");
}while(1);
}
static void th2(void* p) __attribute__ ((l1_text));
static void th2(void* p)
{
RT_EVENT ev;
int ret = rt_event_bind(&ev,"at_evt",TM_NONBLOCK);
if(ret)
{
printf("bind at_evt failed: %s\r\n",strerror(-ret));
exit(1);
}
do
{
rt_task_sleep(100*1000*1000);
rt_event_signal(&ev,1);
}while(1);
}
int main(int argc, const char*argv[])
{
static RT_TASK th;
mlockall(MCL_CURRENT|MCL_FUTURE);
if(rt_task_shadow(&th,"xudaks_main",50,0) != 0)
{
printf("rt_task_shadow failed\r\n");
exit(1);
}
int ret = rt_event_create(&event,"at_evt",0,EV_PRIO);
if(ret)
{
printf("rt_event_create returned %i\r\n",ret);
}
ret = rt_task_create(&task1,"th1",32768,90,T_FPU|T_CPU(0));
rt_task_sleep(0);
if(ret)
{
printf("rt_task_create returned %i\r\n",ret);
}
if(ret == 0)
{
ret = rt_task_start(&task1,th1,0);
rt_task_sleep(0);
if(ret)
{
printf("rt_task_start returned %i\r\n",ret);
}
}
ret = rt_task_create(&task2,"th2",32768,90,T_FPU|T_CPU(0));
rt_task_sleep(0);
if(ret)
{
printf("rt_task_create returned %i\r\n",ret);
}
if(ret == 0)
{
ret = rt_task_start(&task2,th2,0);
rt_task_sleep(0);
if(ret)
{
printf("rt_task_start returned %i\r\n",ret);
}
}
rt_task_sleep(100*1000*1000);
printf("rt_task_sleep\r\n");
do
{
usleep(100000);
printf("usleep\r\n");
}while(1);
return(0);
}