This is the mail archive of the crossgcc@sourceware.org mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problems with Posix Timers (or signals)?


Hi,

I tried to run cyclictest on an embedded x86 board.
 see http://rt.wiki.kernel.org/index.php/Cyclictest

But the Posix Timer did not work as expected.
It looks like after setting up the timer the appropriate signal is never
delivered.

It was pointed out to me that in my case an strace does _not_ show any
function calls releated to posix timers.

I hacked a simple test programm together. Please find it attached. After
starting it should print out

	waiting for signals ... 10

every second und will terminate on SIGINT or SIGUSR2.

The programm works fine on my desktop system and strace indeed reveals

timer_create(CLOCK_REALTIME, {(nil), SIGUSR1, SIGEV_SIGNAL, {...}}, {(nil)}) = 0
timer_settime(0, 0, {it_interval={1, 0}, it_value={1, 0}}, NULL) = 0

But on my target system no such calls appear and the programm blocks in
sigwait().

I am using gcc-4.1.1-glibc-2.3.6-linux-2.6.15.1 built with crosstool-0.43.

Anyone seen the same? Anyone care to test this?

Thanks a million!

Steven
/*
 * simple posix timer test
 *
 */

#include <signal.h>
#include <time.h>

#include <stdio.h>
#include <errno.h>

int main (void)
{
	int ret;
	timer_t timer;
	sigset_t sigset;
	struct sigevent se;
	struct itimerspec tspec;

	se.sigev_signo = SIGUSR1;

	ret = timer_create(CLOCK_REALTIME, &se, &timer);
	if (ret) {
		perror("timer_create() failed");
		return -1;
	}

	tspec.it_value.tv_sec  = 1;
	tspec.it_value.tv_nsec = 0;
	tspec.it_interval.tv_sec  = 1;
	tspec.it_interval.tv_nsec = 0;

	ret = timer_settime(timer, 0, &tspec, NULL);
	if (ret) {
		perror("timer_settime() failed");
		return -1;
	}

	sigemptyset(&sigset);
	sigaddset(&sigset, se.sigev_signo);
	sigaddset(&sigset, SIGINT);
	sigaddset(&sigset, SIGUSR2);
	sigprocmask(SIG_BLOCK, &sigset, NULL);

	while (1) {
		int sig;

		printf("waiting for signals ..."); fflush(stdout);
		if (sigwait(&sigset, &sig) < 0) {
			perror("sigwait() failed");
			goto out;
		}
		printf(" %d\n", sig);

		if (sig == SIGINT)
			goto out;

		if (sig == SIGUSR2)
			goto out;

	}

out:
	printf("timer_delete()\n");
	timer_delete(timer);

	return 0;
}

--
For unsubscribe information see http://sourceware.org/lists.html#faq

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]