From: Philippe Gerum <rpm@xenomai.org>
To: xenomai@xenomai.org, tomz30@domain.hid
Subject: Re: [Xenomai-help] 0 CPU time problem
Date: Sat, 05 Nov 2011 12:27:10 +0100 [thread overview]
Message-ID: <4EB51D8E.9020609@domain.hid> (raw)
In-Reply-To: <4EB45AF6.60304@domain.hid>
On 11/04/2011 10:36 PM, Gilles Chanteperdrix wrote:
> On 11/04/2011 10:03 PM, Tom Z wrote:
>>> We do not know what skin you use, we will assume that you use
>>> Xenomai posix skin, so, compile with the right flags.
>>
>> Here is how I
>> build my program, say, fooTest: gcc -I/usr/xenomai/include
>> -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -lnative
>> -L/usr/xenomai/lib -lxenomai -lpthread -lnative -lrtdk fooTest.c -o
>> fooTest
>
> You are using the native skin then.
>
>>> CLOCK_PROCESS_CPUTIME_ID is not implemented for xenomai posix skin,
>>> so, clock_gettime probably returns an error, and the struct timespec
>>> is unchanged. If somehow the glibc clock_gettime is used, and this
>>> call does not cause a system call, then all bets are off, and even a
>>> lockup could happen.
>>
>> Thanks for explaining this. So can I trust the
>> CPU time I obtained with my method when the function is running in
>> the primary mode? It seems you explanation implies that the results I
>> obtained are not reliable, if so, are there other reliable ways to
>> obtain the CPU time?
>
> No, CLOCK_PROCESS_CPUTIME is a clock implemented by the Linux kernel,
> so, it does not see the time spent in primary mode. If the foo function
> does not suspend, you can use rt_timer_tsc(), but the answer is no,
> there is currently no way to get the cpu time used when in primary mode.
>
There is one, but deeply buried in the API basement, via rt_task_inquire():
RT_TASK_INFO info;
RTIME start;
ret = rt_task_inquire(NULL, &info); /* NULL means current task */
if (ret)
goto Houston_handles_the_problem;
start = info.exectime;
... do work ....
ret = rt_task_inquire(NULL, &info);
delta = info.exectime - start; /* elapsed CPU time in ns */
rt_task_inquire() will beget a syscall each time invoked though, so it
does have some overhead. You need CONFIG_XENO_OPT_STATS enabled in your
Kconfig for this feature (defaults to on).
--
Philippe.
prev parent reply other threads:[~2011-11-05 11:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-04 19:08 [Xenomai-help] 0 CPU time problem Tom Z
2011-11-04 19:21 ` Gilles Chanteperdrix
2011-11-04 21:03 ` Tom Z
2011-11-04 21:36 ` Gilles Chanteperdrix
2011-11-05 2:31 ` Tom Z
2011-11-05 13:33 ` Gilles Chanteperdrix
2011-11-05 11:27 ` Philippe Gerum [this message]
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=4EB51D8E.9020609@domain.hid \
--to=rpm@xenomai.org \
--cc=tomz30@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.