All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Glatz <andreasglatz@domain.hid>
To: xenomai@xenomai.org
Subject: Re: [Xenomai-core] Kernel crash in xnheap_test_and_free	(native/heap.c)
Date: Wed, 18 Mar 2009 13:04:55 -0400	[thread overview]
Message-ID: <1237395895.3441.6.camel@domain.hid> (raw)
In-Reply-To: <1237393895.5495.7.camel@domain.hid>

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


The last source code I sent is outdated.

The newest version with a sighandler for SIGINT is attached here.

Sorry for that,

Andreas



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

#include <rtdk.h>
#include <native/pipe.h>
#include <native/task.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>

static RT_TASK			m_task;
static RT_PIPE			m_pipe;
static volatile int		cont	= 1;

void sig_hdl(int sig) 
{
	cont	= 0;
}


#define rc_error(fn, ret)	rt_printf("Error: " fn ":%s (%d) %s\n", strerror(-ret), -ret)

int main(void)
{
	int			err;
	const char*	out_str		= "d";
	int			out_str_len	= 1;
	int			in_str_len	= 32;
	char		in_str[in_str_len];

	// Lock pages in memory
	mlockall(MCL_CURRENT|MCL_FUTURE);

	// Init rtdk framework for rt_printf
	rt_print_auto_init(1);

	// Catch SIG_INT
	signal(SIGINT, sig_hdl);

	// Add rt shadow
	err	= rt_task_shadow(&m_task, "main", 22, 0);
	if(err) {
		rc_error("rt_task_shadow", err);
		return err;
	}

	// Create pipe
	err	= rt_pipe_create(&m_pipe, "rtp0", 0, 2048);
	if(err) {
		rc_error("rt_pipe_create", err);
		goto cleanup;
	}

	// Deliberately fill pipe without a reader on
	// the other side...
	while(1) {
		err	= rt_pipe_stream(&m_pipe, out_str, out_str_len);
		// Check if there was an error
		if(err < 0) {
			rc_error("rt_pipe_stream", err);
			goto cleanup;
		}
		// Check if all bytes where written to the pipe
		if(err != out_str_len) {
			rt_printf("Info: rt_pipe_stream is full (ret=%d)\n", err);
			break;
		}
	}

	// Wait for the user to connect to the pipe and 
	// loop until we are able to read a byte
	while(cont) {
		err	= rt_pipe_read(&m_pipe, in_str, in_str_len, TM_NONBLOCK);
		if(err < 0 && err != -EAGAIN) {
			rc_error("rt_pipe_read", err);
			goto cleanup;
		}
		// Check if we received something	
		if(err >= 0) {
			rt_printf("Received: %d bytes\n", err);
			break;
		}

		// Wait 1ms
		rt_task_sleep(1000000);
	}
	err	= 0;

cleanup:
	rt_pipe_delete(&m_pipe);
	rt_task_delete(&m_task);
	return err;
}

  reply	other threads:[~2009-03-18 17:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-18 16:31 [Xenomai-core] Kernel crash in xnheap_test_and_free (native/heap.c) Andreas Glatz
2009-03-18 17:04 ` Andreas Glatz [this message]
2009-03-18 17:38   ` Philippe Gerum
2009-03-18 21:53 ` Philippe Gerum
2009-03-18 22:01   ` Philippe Gerum
2009-03-19 13:24     ` Andreas Glatz

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=1237395895.3441.6.camel@domain.hid \
    --to=andreasglatz@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.