All of lore.kernel.org
 help / color / mirror / Atom feed
From: mani bhatti <imranbashirbhatti@domain.hid>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai@xenomai.org
Subject: [Xenomai-help] problem persists with rt_queue
Date: Wed, 6 Dec 2006 07:04:07 -0800 (PST)	[thread overview]
Message-ID: <995989.36703.qm@domain.hid> (raw)
In-Reply-To: <45463851.3030202@domain.hid>


[-- Attachment #1.1: Type: text/plain, Size: 1751 bytes --]


Hi 
I had a problem of rt_queue overflow in xenomai 2.1.Then installed xenomai 2.2.5 but previous poblem with rt_queue is still there.I repeat the problem that when there is no listener on the queue the sender the sender displays the error message 

rt_queue_send(queue_input) failed sent bytes: 0
rt_queue_send(queue_input) failed sent bytes: 0
rt_queue_send(queue_input) failed sent bytes: 0
rt_queue_alloc(queue_inout, 8) failed


 and then stops and if i try to start my program again following message 

start
rt_queue_alloc(queue_inout, 8) failed
Segmentation fault

is displayed and program doesnot work at all.I would be very thankful for the correcting me what wrong am i doing.the code for the sender is attached.


Jan Kiszka <jan.kiszka@domain.hid> wrote: mani bhatti wrote:
> Thanks Jan .
> I have executed # patch -p0 < native-queue-bcast-fix.patch in directory where xenomai is installed and in my case it is  /usr/xenomai directory but sender still goes out of memory  if no  listener  is  waiting on the queue and displays the message
> 
> rt_queue_alloc(queue_inout, 8) failed
> 
> After this message is displayed and i try to execute sender again then sender doesnot execute at all and simply displays above message so i need to restart my computer if i want to eecute sender again .Should i execute patch in some other directory or  is it some other problem?

Nope. Executing your original test case after applying my patch (AND
rebuilding Xenomai - did you check if the kernel you run got updated?)
clearly demonstrated on my box that the problem was fixed.

I would suggest to do a clean rebuild from latest SVN.

Jan



 
---------------------------------
Any questions?  Get answers on any topic at Yahoo! Answers. Try it now.

[-- Attachment #1.2: Type: text/html, Size: 2154 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 3236561751-queue_sender.c --]
[-- Type: text/x-csrc; name="queue_sender.c", Size: 3264 bytes --]

#include <math.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/io.h>
#include <sys/mman.h>

#include <native/task.h>
#include <native/queue.h>
#include <native/intr.h>


#define STACK_SIZE 8192
#define STD_PRIO1 2
#define STD_PRIO2 1
#define QUEUE_INPUT_LEN		1024
#define USE_READ_WRITE
RT_TASK zaehler1_task_ptr;
RT_TASK zaehler2_task_ptr;
int count1 = 0;
int count2 = 0;
int i;
int end = 0;
typedef struct  {
	int counter;
	int data;
}TInputData;

int missedpackets=0;

RT_QUEUE queue_input;


//                      --s-ms-us-ns
RTIME task_period_ns1 =   10000000llu;
RTIME task_period_ns2 =  10000000000llu;

void zaehler1_task(void *cookie){
        
  int ret;
  TInputData sendData;
   memset(&sendData, 0, sizeof(TInputData));



// ************************* Xenomai-Krempel ********************************************************************
        ret = rt_task_set_periodic(NULL, TM_NOW, rt_timer_ns2ticks(task_period_ns1));
        if (ret) {
                printf("error while set periodic, code %d\n",ret);
                return;
        }
// ************************* Ende Xenomai-Krempel ****************************************************************


// ********************** Beginn des wiederholt ausgefuehrten Codes **********************************************
        while(!end){
            
               rt_task_wait_period(NULL);


		void *msg = rt_queue_alloc(&queue_input, sizeof(TInputData));
		if(msg == NULL) {
			printf("rt_queue_alloc(queue_inout, %d) failed\n", sizeof(TInputData));
			
                     }
		memcpy(msg, &sendData, sizeof(TInputData));
		int bytesSent = rt_queue_send(&queue_input, msg,sizeof(TInputData), Q_BROADCAST);
		
                  if (bytesSent <= 0) {
		  	
                    printf("rt_queue_send(queue_input) failed sent bytes: %d\n", bytesSent);
			rt_queue_free(&queue_input, msg);
		 	
		}

		
                sendData.counter++;  
      }
// ********************** Ende des wiederholt ausgefuehrten Codes ***********************************************
}




// signal-handler, to ensure clean exit on Ctrl-C
void clean_exit(int dummy) {
	printf("cleanup\n");
	end = 1;
	rt_task_delete(&zaehler1_task_ptr);
	rt_task_delete(&zaehler2_task_ptr);
	printf("end\n");
}

int main(int argc, char *argv[]) {
	int err, ret;
	
       int res;
	res = mlockall(MCL_CURRENT | MCL_FUTURE);
	if (res < 0) {
		printf("mlockall failed: %d\n", res);
		
	}
        // INPUT_QUEUE
	res = rt_queue_create(&queue_input, "queue_input", sizeof(TInputData) * QUEUE_INPUT_LEN,
		QUEUE_INPUT_LEN, Q_FIFO | Q_SHARED);
	if (res == -EEXIST)  {
		res = rt_queue_bind(&queue_input, "queue_input", 1000);
		//rt_queue_clear(&queue_input);
	}
	if (res < 0) {
		printf("rt_queue_create(queue_input) failed: %d\n", res);
		
	}

	

 
       printf("start\n");
	// install signal handler
	signal(SIGTERM, clean_exit);	
	signal(SIGINT, clean_exit);	

	/* create zaehler1_task */
	err = rt_task_create(&zaehler1_task_ptr,"alpha",STACK_SIZE,STD_PRIO1,0);

	/* start zaehler1_task */
	err = rt_task_start(&zaehler1_task_ptr,&zaehler1_task,NULL);

	// wait for signal & return of signal handler
	pause();
	fflush(NULL);
	return 0;
}

  reply	other threads:[~2006-12-06 15:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-16 15:39 [Xenomai-help] Problem with rt_queue mani bhatti
2006-10-16 15:50 ` Jan Kiszka
2006-10-16 15:58 ` Philippe Gerum
2006-10-25 14:34   ` mani bhatti
2006-10-25 22:50     ` Jan Kiszka
2006-10-27 15:13       ` mani bhatti
2006-10-27 16:52         ` Jan Kiszka
2006-10-30 16:08           ` mani bhatti
2006-10-30 17:37             ` Jan Kiszka
2006-12-06 15:04               ` mani bhatti [this message]
2006-12-06 15:30                 ` [Xenomai-help] Re: problem persists " Jan Kiszka
2006-12-06 16:11                   ` mani bhatti
2006-12-06 16:44                     ` Jan Kiszka
2006-10-27 21:23       ` [Xenomai-help] Problem " Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=995989.36703.qm@domain.hid \
    --to=imranbashirbhatti@domain.hid \
    --cc=jan.kiszka@domain.hid \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.