All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Xenomai-forge: SEGFAULT is pSOS skin
@ 2011-09-22 20:15 Ronny Meeus
  2011-09-23 13:00 ` Philippe Gerum
                   ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: Ronny Meeus @ 2011-09-22 20:15 UTC (permalink / raw)
  To: xenomai-help

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

Hello

I have created some time ago a test application for the PSOS interface
of Xenomai.
This is a extensive test that stresses most of the PSOS services we
use in our application. You can find it as an attachment.
It is running fine on Xenomai 2-5-6.
Note that in the test application there is also a benchmarking part.
This is currently disabled, I will fix that later.

Now I'm investigating a switch to xenomai-forge so I tried to run the
same test on this platform.

This is the version I'm using (downloaded today):

meeusr@domain.hid$ git log | head
commit 04b776ed9ff18e197ae43ee552b8e77f42c5e5cb
Author: Philippe Gerum <rpm@xenomai.org>
Date:   Wed Sep 21 21:08:42 2011 +0200

    psos: fix t_ident() with NULL name


The configuration I did:
./configure --prefix=/home/meeusr/repo/xenomai-forge-install
--enable-debug --with-core=mercury

After adding the test to the makefile of the lib/psos/testsuite and
compiling it, I start it by giving the command:
sudo LD_LIBRARY_PATH=/home/meeusr/repo/xenomai-forge-install/lib/ gdb ./rtprint

After some time I observe a crash:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xa7b5d870 (LWP 14707)]
0x00140749 in dtpvh (holder=0x80cfc7c) at
../../include/copperplate/private-list.h:59
59			holder->prev->next = holder->next;
(gdb) bt
#0  0x00140749 in dtpvh (holder=0x80cfc7c) at
../../include/copperplate/private-list.h:59
#1  0x0014079c in pvlist_remove_init (holder=0x80cfc7c) at
../../include/copperplate/private-list.h:120
#2  0x00140e89 in notifier_destroy (nf=0x80cfc48) at notifier.c:195
#3  0x0013fb68 in threadobj_finalize (p=0x80cfbb0) at threadobj-mercury.c:161
#4  0x0014a3ef in __nptl_deallocate_tsd () at pthread_create.c:155
#5  0x0014a97c in start_thread (arg=0xa7b5d870) at pthread_create.c:307
#6  0x00234a4e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:130
(gdb) print *holder
$1 = {next = 0x2, prev = 0x200}

It looks like the holder structure is getting corrupted and this
results in a crash while destroying a task. Please note that this is
not the case all the time, e.g. there are already tasks destroyed
before.
Does anybody has a clue about the problem or how I have to proceed
with the investigation?

Thanks.
Ronny

[-- Attachment #2: rtprint.c --]
[-- Type: text/x-csrc, Size: 19610 bytes --]

#include <psos/psos.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <stdarg.h>
#include <string.h>
#include <copperplate/init.h>


/*************************************************************************/

char buffer[10000];
char *p = buffer;

static void my_printf_flush(void)
{
	printf("%s",buffer);
	p = buffer;
}

static void my_printf(const char *fmt,...)
{
	va_list arg;
	va_start (arg, fmt);
	p += vsprintf(p,fmt,arg);
	va_end (arg);
	
	if ((p-buffer)>8000)
		my_printf_flush();
}

/*************************************************************************/

static void check_inner(const char *fn, int line, const char *msg,
                        int status, int expected)
{
	return;

        if (status == expected)
                return;

        my_printf("FAILED %s:%d: %s returned %d instead of %d - %s\n",
               fn, line, msg, status, expected, strerror(-status));
        
		my_printf_flush();
		
	while (1)
		tm_wkafter(100);
}

#define check(msg, status, expected) check_inner(__FUNCTION__,__LINE__,msg,status,expected)

/*************************************************************************/
static unsigned long error = 0;
static unsigned long ev_error = 0;

typedef struct
{
	unsigned long long start;
	unsigned long long stop;
} timestamp_info;

static void benchmark_start_test(timestamp_info *ts)
{
	ts->start = 0;
}
  
/*
 * static void benchmark_stop_test(timestamp_info *ts)
{
        ts->stop = 0;
}
*/
static void benchmark_stop_and_report_test(timestamp_info *ts,unsigned long count,
                                           const char *fmt,...)
{
	unsigned long long delta;
	va_list arg;
	char output[128];

        memset(output,0,sizeof(output));
	
	ts->stop  =0;
	delta = ts->stop - ts->start;
	va_start (arg, fmt);
	vsprintf(output,fmt,arg);
	va_end (arg);

	if (!count) count = 1;
	my_printf("[err=%ld,ev_err=%ld] %s took %lld ns (%lld usec). %lld ns / cycle\n",
		error,ev_error,output,delta,delta/1000,delta/count);  
}

  
  
/*************************************************************************/

static void test_taskregisters_body(u_long expected_register_value,
                                    u_long b,u_long c,u_long d)
{
	unsigned long reg = 0;
	check("t_getreg",t_getreg(0UL,0UL,&reg),0);
	check("reg",reg,expected_register_value);
	t_delete(0);
}

static void test_taskregisters(void)
{
	unsigned long tid;
	unsigned long args[4] = {0,0,0,0};
	unsigned long reg_value = 0;

	my_printf("%s\n",__FUNCTION__);
 
	check("t_create",t_create("TEST",250,16000,16000,0,&tid),0);
	check("t_setreg",t_setreg(tid,0UL,100UL),0);
	check("t_getreg",t_getreg(tid,0UL,&reg_value),0);
	check("reg_value",reg_value,100);

	args[0] = 100;
	check("t_start",t_start(tid,0,test_taskregisters_body,args),0);
}

/*************************************************************************/

static unsigned long counter;
static int suspendmyself = 0;

static void test_tasksuspend_body(u_long destroy,u_long b,u_long c,u_long d)
{
	while (1)
	{
		counter++;
		tm_wkafter(1);
		if (suspendmyself)
			t_suspend(0);
	}  
}

static void test_tasksuspend(void)
{
	unsigned long tid;
	unsigned long args[4] = {0,0,0,0};
	unsigned long counter_keep;

	my_printf("%s\n",__FUNCTION__);

	suspendmyself = 0;

	check("t_create",t_create("TEST",250,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_tasksuspend_body,args),0);
    
	counter = 0;
	tm_wkafter(5);
	t_suspend(tid);
	counter_keep = counter;
	tm_wkafter(5);
	check("suspend count",counter,counter_keep);
	t_resume(tid);
	tm_wkafter(5);
	if (counter == counter_keep)
		check("resume count",1,0);

	suspendmyself = 1;
	tm_wkafter(5);
	counter_keep = counter;
	tm_wkafter(5);
	check("suspend count",counter,counter_keep);
  
	t_delete(tid);  	  
}     

/*************************************************************************/

static void test_taskcreation_body(u_long destroy,u_long b,u_long c,u_long d)
{
	check("b",b,200);
	check("c",c,300);
	check("d",d,400);

	if (destroy)
		t_delete(0);

	while (1)
		tm_wkafter(1000);
}

static void test_taskcreation_body2(u_long a,u_long b,u_long c,u_long d)
{
	check("a",a,100);
	check("b",b,200);
	check("c",c,300);
	check("d",d,400);
	
	t_delete(0);
}

static void create_and_start_task(unsigned long *tid)
{
	unsigned long local_args[4] = {0,200,300,400};
	check("t_create low prio",t_create ("TEST",2,4000,0,T_LOCAL,tid),0);	
	check("t_start low prio",t_start(*tid,T_PREEMPT|T_TSLICE,test_taskcreation_body,local_args),0);
}
    
static void test_taskcreation(void)
{
	unsigned long tid,tid2;
	unsigned long tids[10];
	unsigned long args[4] = {100,200,300,400};
	int i;

	my_printf("%s\n",__FUNCTION__);
 
	check("t_create",t_create("TEST111",2,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_taskcreation_body2,args),0);

	for (i=1;i<2;i++)
	{
		check("t_create",t_create("TEST",(unsigned long)i,16000,16000,0,&tid),0);
		check("t_start",t_start(tid,T_PREEMPT| T_TSLICE | T_NOASR,test_taskcreation_body2,args),0);
	}  

	args[0] = 1;
	check("t_create",t_create("1TEST",50,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_taskcreation_body,args),0);

	args[0] = 0;
	check("t_create",t_create("2TEST",50,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_taskcreation_body,args),0);
	check("t_ident",t_ident("2TEST",0,&tid2),0);
	check("tid",tid,tid2);
	check("t_delete",t_delete(tid),0);

	/* Create multiple tasks with the same name */   
	args[0] = 0;
	for (i=0;i<1;i++)
	{ 
		check("t_create loop",t_create ("TTTT",64,100000,0,0,&tids[i]),0);
		check("t_start loop",t_start(tids[i],T_PREEMPT,test_taskcreation_body,args),0);   
	}
	check("t_ident loop",t_ident("TTTT",0,&tid2),0);
	check("tid check",tid2,tids[0]);
	for (i=0;i<1;i++)
	{ 
		check("t_delete loop",t_delete(tids[i]),0);
	}

	args[0] = 0;
	for (i=0;i<1;i++)
	{ 
		check("t_create loop2",t_create ("TEST",64,100000,0,0,&tid),0);
		check("t_delete loop2",t_delete(tid),0);
		my_printf("t_create + t_delete %d\r",i);
	}
	my_printf("\n");

	args[0] = 0;
	for (i=0;i<500;i++)
	{ 
		check("t_create loop3",t_create ("TEST",(i%250)+1,100000,0,0,&tid),0);    
		check("t_start loop3",t_start(tid,T_PREEMPT,test_taskcreation_body,args),0);
		check("t_delete loop3",t_delete(tid),0);			       
		my_printf("t_create + t_start + t_delete %d\r",i);
	}
	my_printf("\n");

	args[0] = 0;
	for (i=0;i<1;i++)
	{
		create_and_start_task(&tids[i]);
	}    
	tm_wkafter(10);
	for (i=0;i<1;i++)
	{
		check("t_delete loop3",t_delete(tids[i]),0); 
	}    
	my_printf("\n");
}

/*************************************************************************/

static void test_basicevents(void)
{
	unsigned long mask,ev_rcvd;
	int i;

	mask = 1;
	for (i=0;i<32;i++)
	{
		check("ev_send 1",ev_send(0,mask),0);
		check("ev_receive 1",ev_receive(mask,EV_ALL|EV_NOWAIT,0,&ev_rcvd),0);
		check("received events 1",mask,ev_rcvd);
		mask <<= 1;
	}

	mask = 1;
	for (i=0;i<32;i++)
	{
		check("ev_send many",ev_send(0,mask),0);
		check("ev_receive many",ev_receive(mask,EV_ALL|EV_NOWAIT,0,&ev_rcvd),0);
		check("received events many",mask,ev_rcvd);
		mask = (mask << 1) | 1;
	}
	
	mask = 1;
	for (i=0;i<32;i++)
	{
		check("ev_send once",ev_send(0,mask),0);
		mask <<= 1;
	}
	mask = 0xffffffff;
	ev_rcvd = 0;
	check("ev_receive once",ev_receive(mask,EV_ALL|EV_NOWAIT,0,&ev_rcvd),0);
	check("received events once",0xffffffff,ev_rcvd);
}

static void test_events_body(u_long tid,u_long b,u_long c,u_long d)
{
	test_basicevents();
	ev_send(tid,1);
	t_delete(0);
}

static void test_events(void)
{
	unsigned long tid;
	unsigned long args[4] = {0,0,0,0};
	unsigned long ev_rcvd;

	my_printf("%s\n",__FUNCTION__);
	test_basicevents();
	
	t_ident(0,0,&args[0]);
	check("t_create",t_create("TEST",2,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_events_body,args),0);
	
	ev_receive(1,EV_ALL|EV_WAIT,0,&ev_rcvd);
}

/*************************************************************************/

static void test_queuecreation(void)
{
	unsigned long qid,qid2;
	unsigned long qids[50];
	int i;
  
	my_printf("%s\n",__FUNCTION__);
	check("q_create",q_create("TTTT",0,Q_NOLIMIT|Q_PRIOR,&qid),0);
	check("q_ident",q_ident("TTTT",0,&qid2),0);
	check("compate qids",qid,qid2);
	check("q_delete",q_delete(qid),0);
	
	for (i=0;i<100;i++)
	{ 
		check("q_create",q_create("TTTS",0,Q_NOLIMIT|Q_PRIOR,&qid),0); 
		check("q_delete",q_delete(qid),0); 
	}
	
	for (i=0;i<50;i++)
		check("q_create",q_create("TTTU",0,Q_NOLIMIT|Q_PRIOR,&qids[i]),0);
	for (i=0;i<50;i++) 
		check("q_delete",q_delete(qids[i]),0);
}                          
	
/*************************************************************************/
	
static void test_queue(void)
{
	unsigned long qid;
	unsigned long mesg[4] = {0,1,2,3};
	unsigned long recv_msg[4];
	
	int i;
	char testCaseName[32];
	timestamp_info timeInfo;
	     
	my_printf("%s\n",__FUNCTION__);
	check("q_create",q_create("TEST",0,Q_NOLIMIT|Q_PRIOR,&qid),0);
	check("q_send",q_send(qid,mesg),0);
	check("q_receive",q_receive(qid,Q_NOWAIT,0,recv_msg),0);
	check("q_receive TO",q_receive(qid,Q_WAIT,50,recv_msg),ERR_TIMEOUT);
	
	for (i=0;i<1000;i++)
	{
		sprintf(testCaseName,"q_send LOOP %d",i);
		mesg[3] = (unsigned long)i;
		check(testCaseName,q_send(qid,mesg),0);
	}
	
	i=0;
	while (q_receive(qid,Q_NOWAIT,0,recv_msg) == 0)
	{
		check("MSG 0",recv_msg[0],mesg[0]);
		check("MSG 1",recv_msg[1],mesg[1]);
		check("MSG 2",recv_msg[2],mesg[2]);
		check("MSG 3",recv_msg[3],i++);
	}
	
 	benchmark_start_test(&timeInfo);
	for (i=0;i<1000;i++)
		q_send(qid,mesg);
	benchmark_stop_and_report_test(&timeInfo,i,"q_send");
	
	benchmark_start_test(&timeInfo);
	for (i=0;i<1000;i++) 
		q_receive(qid,Q_NOWAIT,0,recv_msg);
	benchmark_stop_and_report_test(&timeInfo,i,"q_receive");

	check("q_delete",q_delete(qid),0);
}                                    

/*************************************************************************/

static void test_msgqueue_ctxtswitch_body(u_long my_qid,u_long dst_qid,u_long count,u_long tid)
{
	unsigned long recv_msg[4];
	while (count--)
	{
		q_receive(my_qid,Q_WAIT,0,recv_msg);		
		q_send(dst_qid,recv_msg);
	}
	if (tid)
		ev_send(tid,1);
	t_delete(0);
}


static void test_msgqueue_ctxtswitch(void)
{
	unsigned long tid,ev_rcvd;
	unsigned long args[4] = {0,0,0,0};
	unsigned long mesg[4] = {0,1,2,3};
	unsigned long qid1,qid2;
	timestamp_info timeInfo;
	
	my_printf("%s\n",__FUNCTION__);   

	check("q_create",q_create("TEST",0,Q_NOLIMIT|Q_PRIOR,&qid1),0);
	check("q_create",q_create("TEST",0,Q_NOLIMIT|Q_PRIOR,&qid2),0);
 
	args[0] = qid1;
	args[1] = qid2;
 	args[2] = 1000;
	t_ident(0,0,&args[3]); 
	check("t_create",t_create("TEST",50,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_msgqueue_ctxtswitch_body,args),0);

	args[0] = qid2;
	args[1] = qid1;
	args[3] = 0;    /* Make sure only 1 sends the event. */
	check("t_create",t_create("TEST",50,16000,16000,0,&tid),0);
	check("t_start",t_start(tid,0,test_msgqueue_ctxtswitch_body,args),0);
 
	/*send initial message */
	benchmark_start_test(&timeInfo);
	q_send(qid1,mesg);    
	ev_receive(1,EV_ALL|EV_WAIT,0,&ev_rcvd);
	benchmark_stop_and_report_test(&timeInfo,1000,"q_send/q_receive between 2 tasks");

	q_delete(qid1);
	q_delete(qid2);
}

/*************************************************************************/

static void test_event_ctxtswitch_body(u_long dst_tid,u_long count,u_long tid,u_long d)
{
	unsigned long recv_ev;
	while (count--)
	{
		ev_receive(1,EV_WAIT,0,&recv_ev);		
		ev_send(dst_tid,1);
	}
	if (tid)
		ev_send(tid,1);

	t_delete(0);
}


static void test_event_ctxtswitch(void)
{
	unsigned long tid1,tid2,ev_rcvd;
	unsigned long args[4] = {0,0,0,0};
	timestamp_info timeInfo;

	my_printf("%s\n",__FUNCTION__);   

	check("t_create",t_create("TEST",50,16000,16000,0,&tid1),0);
	check("t_create",t_create("TEST",50,16000,16000,0,&tid2),0);

	args[0] = tid2;
	args[1] = 1000;
	t_ident(0,0,&args[2]);
	check("t_start",t_start(tid1,0,test_event_ctxtswitch_body,args),0);

	args[0] = tid1;
	args[2] = 0;    /* Make sure only 1 sends the event. */
        check("t_start",t_start(tid2,0,test_event_ctxtswitch_body,args),0);
 
	/*send initial event */
	benchmark_start_test(&timeInfo);
        ev_send(tid1,1);
	if (ev_receive(1,EV_ALL|EV_WAIT,1000,&ev_rcvd) != 0)
		error++;

	benchmark_stop_and_report_test(&timeInfo,1000,"q_send/q_receive between 2 tasks");
}

/*************************************************************************/

static void test_semaphores(void)
{
	unsigned long smid,smid2;
	unsigned long smids[50];
	timestamp_info timeInfo;
	int i;
      
	my_printf("%s\n",__FUNCTION__);
	check("sm_create",sm_create("TTTT",0,SM_PRIOR,&smid),0);
	check("sm_ident",sm_ident("TTTT",0,&smid2),0);
	check("compare smids",smid,smid2);
	check("sm_delete",sm_delete(smid),0);

	for (i=0;i<100;i++)
	{ 
		check("sm_create",sm_create("TTTT",0,SM_PRIOR,&smid),0);
		check("sm_delete",sm_delete(smid),0);
	}

	for (i=0;i<50;i++)
		check("sm_create",sm_create("TTTT",0,SM_PRIOR,&smids[i]),0);
	for (i=0;i<50;i++)
		check("sm_delete",sm_delete(smids[i]),0);
        

	check("sm_create",sm_create("TTTT",0,SM_PRIOR,&smid),0);
	benchmark_start_test(&timeInfo);
	for (i=0;i<1000;i++)
	{
		sm_v(smid);
		sm_p(smid,SM_WAIT,0);
	}
	benchmark_stop_and_report_test(&timeInfo,i,"sm_v/sm_p");
	check("sm_delete",sm_delete(smid),0);
}     

/*************************************************************************/

static void test_regions(void)
{
	void *ptr;
	unsigned long rnid,rsize;

	my_printf("%s\n",__FUNCTION__);
	check("rn_create x",rn_create("TEST",0,128000, 128, 0, &rnid, &rsize),0);
	check("rn_getseg x",rn_getseg(rnid,100,RN_NOWAIT,0,&ptr),0);
	check("rn_retseg x",rn_retseg(rnid,ptr),0);
	check("rn_delete x",rn_delete(rnid),0);
}

static void test_region0_malloc_free(void)
{
        void *ptr;
        unsigned long i;

        my_printf("%s\n",__FUNCTION__);
        for (i=0;i<1000;i++)
	{ 
		check("rn_getseg 0",rn_getseg(0,100,RN_NOWAIT,0,&ptr),0);
        	check("rn_retseg 0",rn_retseg(0,ptr),0);
	}
}

static void test_timers(void)
{
	unsigned long tmr_id,ev_rcvd,ret;
	timestamp_info timeInfo;
	int i;

	ev_receive(1,EV_ANY|EV_NOWAIT,0,&ev_rcvd);

	// Test tm_evevery
	check("tm_evevery",tm_evevery(1,1,&tmr_id),0);
	benchmark_start_test(&timeInfo);
	for (i=0;i<11;i++)
	{
		check("ev_receive",ev_receive(1,EV_ANY|EV_WAIT,100,&ev_rcvd),0);
		check("eventmask",ev_rcvd,1);
		if (i==10)
			check("tm_cancel",tm_cancel(tmr_id),0);
		else
			benchmark_stop_and_report_test(&timeInfo,i,"tm_evevery 1 (TO %d)",i);
	}
	ev_rcvd = 0;
	ret = ev_receive(1,EV_ANY|EV_NOWAIT,0,&ev_rcvd);

	// Test tm_evafter
	ev_rcvd = 0;
	check("tm_after",tm_evafter(10,2,&tmr_id),0);
	check("ev_receive 2",ev_receive(3,EV_ANY|EV_WAIT,20,&ev_rcvd),0);
	check("eventmask 2",ev_rcvd,2);		
	tm_cancel(tmr_id);

	tm_wkafter(20);
	// Check whether new event is received.
	ev_rcvd = 0;
	ev_receive(2,EV_ANY|EV_NOWAIT,0,&ev_rcvd);
	if (ev_rcvd != 0)
	{
		my_printf("ev_receive 888 %ld\n",ev_rcvd);
		ev_error++;
	}

	// Test tm_cancel
	ev_rcvd = 0;
	check("tm_evevery",tm_evevery(3,4,&tmr_id),0);
	ret = ev_receive(7,EV_ANY|EV_NOWAIT,0,&ev_rcvd);
	my_printf("ev_receive 0 returned %ld (events=%ld)\n",ret,ev_rcvd);

	check("tm_cancel",tm_cancel(tmr_id),0);
	ev_rcvd = 0;
	ret = ev_receive(4,EV_ANY|EV_WAIT,10,&ev_rcvd);
	if (ret == 0)
	{
		ev_error++;
		my_printf("ev_receive returned %ld (events=%ld)\n",ret,ev_rcvd);
	}
	check("ev_receive",ret,ERR_TIMEOUT);

	check("tm_evafter",tm_evafter(100,8,&tmr_id),0);

	// TODO: The event is receive already after starting the timer.
	// If the line below is commented-out the code is not working.
	ev_rcvd = 0;
	ret = ev_receive(8,EV_ANY|EV_NOWAIT,0,&ev_rcvd);
        my_printf("ev_receive 1 returned %ld (events=%ld)\n",ret,ev_rcvd);

        check("tm_cancel",tm_cancel(tmr_id),0);
	ev_rcvd = 0;
	ret = ev_receive(8,EV_ANY|EV_WAIT,200,&ev_rcvd);
        my_printf("ev_receive 2 returned %ld (events=%ld)\n",ret,ev_rcvd);	
        check("ev_receive",ret,ERR_TIMEOUT);

	// clear pending events
	ev_rcvd = 0;
	ev_receive(0xffffffff,EV_ANY|EV_NOWAIT,0,&ev_rcvd);
}

/*************************************************************************/

static void test_timeservices(void)
{
}

static void test_debuginterface(void)
{
	unsigned long qid,guard_tmr;
	unsigned long mesg[4] = {0,1,2,3};
	void *ptr;
	unsigned long rnid,rsize;
    
	q_create("0MSG",0,Q_NOLIMIT|Q_PRIOR,&qid);
	q_create("1MSG",0,Q_NOLIMIT|Q_PRIOR,&qid); 

	check("rn_create",rn_create("ISAM",0,128000, 128, 0, &rnid, &rsize),0);
	check("rn_getseg 0",rn_getseg(rnid,100,RN_NOWAIT,0,&ptr),0);
	my_printf("allocated buffer: %p\n",ptr);
     
	q_send(qid,mesg);

	tm_evevery(1000,0x8000,&guard_tmr);
	my_printf("TimerId (1000): %ld\n",guard_tmr);

	tm_evevery(5000,0x4000,&guard_tmr);
	my_printf("TimerId (5000): %ld\n",guard_tmr);
}

/*************************************************************************/

static void test_main_body(u_long destroy,u_long b,u_long c,u_long d);
int main(int argc, char **argv)
{
        unsigned long tid;
        unsigned long args[4] = {0,0,0,0};

        copperplate_init(argc, argv);

        check("t_create",t_create("TEST",50,16000,16000,0,&tid),0);
        check("t_start",t_start(tid,0,test_main_body,args),0);

	while (1) tm_wkafter(1000);

	return 0;

}

static void test_main_body(u_long destroy,u_long b,u_long c,u_long d)
{ 
	int i = 0;
	char testCaseName[32];
	int count = 1000;

	for (i=0;i<count;i++)
	{
		unsigned long tid;
		unsigned long args[4] = {0,200,300,400};

		sprintf(testCaseName,"t_create %d",i);         
		check(testCaseName,t_create ("TEST",(i%250)+1,100000,0,0,&tid),0);    
		sprintf(testCaseName,"t_start %d",i);
		check(testCaseName,t_start(tid,T_PREEMPT,test_taskcreation_body,args),0);
		sprintf(testCaseName,"t_delete %d",i);
		check(testCaseName,t_delete(tid),0);                                         
		if ((i%1000) == 0) my_printf("create + start + delete %d\n",i);
	}

	for (i=0;i<count;i++)
	{
		unsigned long tid;
		unsigned long args[4] = {100,200,300,400};

		sprintf(testCaseName,"t_create %d",i);
		check(testCaseName,t_create ("TEST",(i%250)+1,100000,0,0,&tid),0);    
		sprintf(testCaseName,"t_start %d",i);
		check(testCaseName,t_start(tid,T_PREEMPT,test_taskcreation_body2,args),0);
		if ((i%1000) == 0) my_printf("create + start + self delete %d\n",i);
	}

	for (i=0;i<count;i++)
	{ 
		unsigned long smid;

		sprintf(testCaseName,"sm_create %d",i);
		check(testCaseName,sm_create("TTTT",0,SM_PRIOR,&smid),0);
		sprintf(testCaseName,"sm_delete %d",i);
		check(testCaseName,sm_delete(smid),0);
		if ((i%1000) == 0) my_printf("sm_create + sm_delete %d\n",i);
	}

	for (i=0;i<count;i++)
	{  	 
		unsigned long qid;

		sprintf(testCaseName,"q_create %d",i);
		check(testCaseName,q_create("TTTT",0,Q_NOLIMIT|Q_PRIOR,&qid),0);
		sprintf(testCaseName,"q_delete %d",i);
		check(testCaseName,q_delete(qid),0);
		if ((i%1000) == 0) my_printf("q_create + q_delete %d\n",i);              
	}

	// Execute this test only once since the kernel memory is mapped into userspace
	// and it only released once the process is killed.
	test_regions();
        test_debuginterface();

	i = 0;
	while (1)
	{
 		printf("Iteration : %d\n\r",i++);

		test_taskcreation();
		test_taskregisters();
		test_tasksuspend();
		
		test_queuecreation();
		test_queue();
		test_msgqueue_ctxtswitch();
		test_events();
		test_event_ctxtswitch();

		test_semaphores();
		test_region0_malloc_free();
		test_timeservices();
		test_timers();

		tm_wkafter(100);

		my_printf_flush();

	}
	while (1)
		tm_wkafter(1000);
}

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2011-11-18 10:57 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22 20:15 [Xenomai-help] Xenomai-forge: SEGFAULT is pSOS skin Ronny Meeus
2011-09-23 13:00 ` Philippe Gerum
2011-09-23 20:21   ` Ronny Meeus
2011-09-23 20:23     ` Philippe Gerum
2011-09-26 10:46       ` Philippe Gerum
2011-09-26 20:01         ` Ronny Meeus
2011-09-26 21:11           ` Philippe Gerum
2011-11-01 11:52             ` Philippe Gerum
2011-11-18 10:57               ` Thomas De Schampheleire
2011-10-04 15:41           ` Philippe Gerum
2011-10-12 17:16             ` Ronny Meeus
2011-10-12 17:19               ` Philippe Gerum
2011-09-23 13:56 ` Gilles Chanteperdrix
2011-09-23 17:05   ` Ronny Meeus
2011-09-23 17:20     ` Gilles Chanteperdrix
2011-09-23 19:58       ` Ronny Meeus
2011-09-26 10:49 ` Philippe Gerum
2011-09-26 20:02   ` Ronny Meeus
2011-09-26 20:57     ` Philippe Gerum

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.