public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Gary Thomas <gary@mlbassoc.com>
To: moktar_bouain <moktarbouain@yahoo.fr>
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] measure the execution time of each thread
Date: Mon, 25 Apr 2011 12:36:00 -0000	[thread overview]
Message-ID: <4DB56AB2.50109@mlbassoc.com> (raw)
In-Reply-To: <31468181.post@talk.nabble.com>

On 04/24/2011 04:22 PM, moktar_bouain wrote:
>
>> You don't want to modify that code, just look at how it computes time
>> at a nanosecond scale.
>> Look at the function show_time_in_us() which uses time values
>> based on the function HAL_CLOCK_READ() that reads the system timer
>> (whatever that may be) and calculates time to the most accurate
>> value available in the system.  This is based on the raw clock
>> (often the hardware system clock) that's used to run the system
>> 'tick' timer.  On most systems, this value is accurate to micro-seconds,
>> sometimes even nano-seconds.
>
> Hi Gary,
> I found the function gettimeofday() which returns the time  in  us.
> I create a simple application with eCos containing 1 thread,i like to
> measure the
> execution time(us) of the thread.
>
> void taska(cyg_addrword_t data)
> {
> struct timeval tv1,tv2;
> long long diff;
>
> while(1)
> {
> gettimeofday (&tv1, NULL);
>
> cyg_mutex_lock(&cliblock);
> printf("TASKA \n");
> cyg_mutex_unlock(&cliblock);
>
> cyg_thread_delay(2);
>
> gettimeofday (&tv2, NULL);
> diff=(tv2.tv_sec-tv1.tv_sec) * 1000000 + (tv2.tv_usec-tv1.tv_usec);
>
> printf("Time tv1 is %d\n",tv1.tv_usec);
> printf("Time tv2 is %d\n",tv2.tv_usec);
> printf("The diff is =%d usec\n",diff);
> };
> }
>
> when i run this application in Tsim(simulator of Leon3):
> Time tv1 is 286326803
> Time tv2 is 286326801
> The diff is -1 usec
> Can you tell me what the fault in my program?

Looks like HAL_CLOCK_READ() isn't working on your hardware.
What's your target hardware?  Is it part of the public eCos tree?

-- 
------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
------------------------------------------------------------

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

  reply	other threads:[~2011-04-25 12:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-15 17:11 moktar_bouain
2011-04-18 17:03 ` Michael Bergandi
2011-04-18 22:01   ` moktar_bouain
2011-04-18 22:50     ` Gary Thomas
2011-04-18 23:32       ` moktar_bouain
2011-04-19 11:07         ` Gary Thomas
2011-04-22 23:00           ` moktar_bouain
2011-04-23 14:33             ` Gary Thomas
2011-04-23 15:07               ` moktar_bouain
2011-04-23 17:11                 ` Gary Thomas
2011-04-24 22:22                   ` moktar_bouain
2011-04-25 12:36                     ` Gary Thomas [this message]
2011-04-28  2:39                       ` moktar_bouain
2011-04-19  6:06 ` Yurij Grechishhev

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=4DB56AB2.50109@mlbassoc.com \
    --to=gary@mlbassoc.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=moktarbouain@yahoo.fr \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).