All of lore.kernel.org
 help / color / mirror / Atom feed
From: adam8157@gmail.com (Adam Lee)
To: kernelnewbies@lists.kernelnewbies.org
Subject: setitimer shows different between amd64 and ia32
Date: Mon, 25 Jul 2011 11:10:38 +0800	[thread overview]
Message-ID: <20110725031038.GA11399@adam-laptop> (raw)

Hi, all

I'm working on a test which invoking setitimer(), and it hang in
ia32 and ppc, but passed in amd64, could you guys give some help?

1, I know the 'value.it_interval.tv_usec' is too short, but why amd64
passed?

2, If I switch clock source from "tsc" to "hpet" on ia32, it passed.

3, I compiled it in ia32 and run it with ia32-libs in amd64, it passed.


Here is the source:


#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include <errno.h>

#define LOOP_LIMIT  1E2

volatile int sigcount = 0;

void catcher(int sig)
{
	struct itimerval value;
	int which = ITIMER_REAL;
	sigcount++;
	if (sigcount > 1) {
		getitimer(which, &value);
		value.it_value.tv_sec = 0;
		value.it_value.tv_usec = 0;
		/*setitimer( which, &value, NULL ); */
	}
}

int main(int argc, char *argv[])
{
	int result = 0;
	struct itimerval value, ovalue, pvalue;
	int which = ITIMER_REAL;
	struct sigaction sact;
	volatile double count;
	time_t t;

	sigemptyset(&sact.sa_mask);
	sact.sa_flags = 0;
	sact.sa_handler = catcher;
	sigaction(SIGALRM, &sact, NULL);
	getitimer(which, &pvalue);

	/*Set a real time interval timer to repeat */
	value.it_interval.tv_sec = 0;
	value.it_interval.tv_usec = 1;
	value.it_value.tv_sec = 0;
	value.it_value.tv_usec = 5;
	result = setitimer(which, &value, &ovalue);

	/*The interval timer value returned by setitimer() should be */
	/*identical to the timer value returned by getitimer() */
	if (ovalue.it_interval.tv_sec != pvalue.it_interval.tv_sec ||
	    ovalue.it_interval.tv_usec != pvalue.it_interval.tv_usec ||
	    ovalue.it_value.tv_sec != pvalue.it_value.tv_sec ||
	    ovalue.it_value.tv_usec != pvalue.it_value.tv_usec) {
		printf("Real time interval timer mismatch, test Failed\n");
		result = -1;
	}
	time(&t);
	printf("Before loop, time is %s", ctime(&t));

	for (count = 0; ((count < LOOP_LIMIT)); count++) ;
	time(&t);
	printf("After loop, time is %s\n", ctime(&t));

	if (sigcount == 0)
		printf("The signal catcher never gained control\n");
	else
		printf("The signal catcher gained control\n");

	printf("The value of count is %.0f\n", count);

	return (result);
}


-- 
Regards,
Adam Lee
--------------------------------------------------
E-mail: adam8157@gmail.com
Website: http://www.adam8157.info
--------------------------------------------------

             reply	other threads:[~2011-07-25  3:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-25  3:10 Adam Lee [this message]
2011-07-25  4:06 ` setitimer shows different between amd64 and ia32 Mulyadi Santosa
2011-07-25  4:09 ` Dave Hylands
2011-07-25  6:51   ` Adam Lee

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=20110725031038.GA11399@adam-laptop \
    --to=adam8157@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.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.