Hi, everyone
I am trying the posix skin under xenomai 2.6.4 with the Linux kernel 3.14.17.
I created a thread and try to make it periodic, but the
pthread_make_periodic_np failed with ESRCH which indicates that the thread is
invalid. This is impossible since the print work of thread continues. The test
code and compile commands given by eclipse go as following, can anybody give me
some suggestion or help me to figure it out?
3Q for your patience.
*********************************************************************************************************
/*
* testposixskin.c
*
* Created on: 2018年4月12日
* Author: root
*/
#include <posix/posix.h>
#include<unistd.h>
pthread_t tid;
volatile thread_counter;
void* start(void* arg) {
while (1) {
thread_counter++;
printf("thread_counter=%d\n", thread_counter);
usleep(100000);
pthread_wait_np();
}
}
struct timespec now;
struct timespec starttp;
struct timespec periodtp;
int main() {
thread_counter = 0;
int ret = -1;
ret = pthread_create(&tid, NULL, start, NULL);
printf("ret=%d\n", ret);
if (ret == EINVAL) {
printf("ret==EINVAL,\n");
}
if (ret == EAGAIN) {
printf("ret==EAGAIN,,\n");
}
if (ret == EINVAL) {
printf("ret==EINVAL,\n");
}
periodtp.tv_sec = 1;
periodtp.tv_nsec = 0;
clock_gettime(CLOCK_REALTIME, &now);
starttp.tv_sec = now.tv_sec + 1;
starttp.tv_nsec = now.tv_nsec;
ret = pthread_make_periodic_np(&tid, &starttp, &periodtp);
printf("ret=%d\n", ret);
if (ret == ESRCH) {
printf("ret==ESRCH\n");
}
if (ret == ETIMEDOUT) {
printf("ret==ETIMEDOUT\n");
}
sleep(10);
return 0;
}
*********************************************************************************************************
gcc -I/usr/xenomai/include -O0 -g3 -Wall -c -fmessage-length=0 -D_GNU_SOURCE
-D_REENTRANT -D__XENO__ -MMD -MP -MF"src/testposixskin.d"
-MT"src/testposixskin.o" -o "src/testposixskin.o" "../src/testposixskin.c"
gcc -L/usr/xenomai/lib -Xlinker -rpath -Xlinker /usr/xenomai/lib -o
"testposixskin" ./src/testposixskin.o -lnative -lpthread_rt -lxenomai -lrt
-lpthread
*********************************************************************************************************
yours: Kira Yamato
2018-04-13
_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai