All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] Meassage Queue c++
@ 2006-01-18 13:44 Stephan Zimmermann
  0 siblings, 0 replies; 7+ messages in thread
From: Stephan Zimmermann @ 2006-01-18 13:44 UTC (permalink / raw)
  To: xenomai

Hello again,
still experimenting with Xenomai and C++, I did wrap a class aroud the 
rt_queue functions. This produces a suspicious bug wich I am unable to track 
down. Perhaps someone here can help.

I start two Tasks, both are instances of my Thread-class. Both Tasks call the 
constructor of my queue-class, creating an queue-object. The first one really 
creates it, the second one gets an -EEXIST error inside the constructor and 
does bind to the queue. Now both tasks have their own queue-object, 
describing the same rt_queue. (in proc everything seems good)

Now, I can write messages to the queue, wich works well. I also can read the 
queue from the other task without problems. Only if the queue is empty and 
the task attempts to read from it, my program crashes without any error- or 
log-message.

A Testprogram in plain C works well, so It must be s.th. with my C++ Classes.

Here is some Code (compiles without warnings):

Constructor:

BM_Queue::BM_Queue(const char* name, size_t size, size_t qlimit, int mode){
	name = name;
	size = size;
	qlimit = qlimit;
	mode = mode;	
	int err = rt_queue_create(&q,name,size,qlimit,mode);
	std::cout << "Constructor queue: create " << err << std::endl;
	if(err == -EEXIST){
		err = rt_queue_bind(&q,name,100000000);
		std::cout << "Konstruktor bm_queue: bind " << err << std::endl;
	}
	switch(err){
		case 0:				usecount++;
							break;
		default:				throw queue_exception(err);
							break;
	}
}


Recieve Function:

void* BM_Queue::rcv(unsigned long int timeout){	
	void* message;
	void* data;
	size_t size = rt_queue_recv(&q,&message,TM_INFINITE);	// blocking won't work!
	std::cout << "Recieve from queue: " << size << std::endl;
	if(size < 0){
		std::cout << "ERROR Q throwing exception: " << size << std::endl; 
		/*--- This exception is not thrown, it simply crashes ---*/
		throw queue_exception(size);
	}
	data = malloc(size);	//using operator new here (and delete there), does not 
change things
	memcpy(data,message,size);
	rt_queue_free(&q,message);
	return data;
}

Any Ideas?


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

end of thread, other threads:[~2006-01-24 16:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <43CFC6B5.8080308@domain.hid>
2006-01-20  8:14 ` [Xenomai-help] Meassage Queue c++ Stephan Zimmermann
2006-01-20  8:37   ` Jan Kiszka
2006-01-20  8:48     ` Stephan Zimmermann
2006-01-20  9:30       ` Jan Kiszka
2006-01-20 12:13         ` Stephan Zimmermann
2006-01-24 16:42         ` Stephan Zimmermann
2006-01-18 13:44 Stephan Zimmermann

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.