public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] Questions about cpuload package and idle thread.
@ 2004-08-13  4:20 kbchoi
  2004-08-13  7:14 ` Andrew Lunn
  0 siblings, 1 reply; 6+ messages in thread
From: kbchoi @ 2004-08-13  4:20 UTC (permalink / raw)
  To: ecos-discuss

Hello..

    I'm using the sample "cpuload" packages in "/ecos/packages/services".
cyg_cpuload_calibrate( ) which is in the first part of test program is using idle thread.
As I know in "idle thread", the value of idle_thread_loops is increasing continuously.
Because I want to know the action of idle thread, I modified the cyg_cpuload_calibrate( ) as following.

cyg_cpuload_calibrate(cyg_uint32  *calibration)
{
   cyg_handle_t counter;
   cyg_alarm alarm_s;
   cyg_handle_t alarmH;
   cyg_handle_t idleH;
   cyg_uint32 idle_loops_start;
   cyg_priority_t old_priority, cur_priority;
   int   i,j;

   cyg_thread_create(1,
       idle_thread_main,
       0,
       "Calibration idle thread",
       idle_stack,
       sizeof(idle_stack),
       &idleH,
       &thread);

   xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
   for (i = 0 ; i < 100000 ; i++)
      j = i;	// useless work..
   xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
   cyg_thread_delay(100);
   xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
}

And the result of this code is following.

	cyg_cpuload_calibrate #1 : idle_thread_loops = 0
	cyg_cpuload_calibrate #2 : idle_thread_loops = 0
	cyg_cpuload_calibrate #3 : idle_thread_loops = 512bc

Then is idle thread working without cyg_thread_resume( ) ?
And If so, why the second value of idle_thread_loops is "0" ?
These are my questions about cpuload package and idle thread.
Please let me know...
Thanks in advance.

		KBCHOI

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ECOS] Questions about cpuload package and idle thread.
  2004-08-13  4:20 [ECOS] Questions about cpuload package and idle thread kbchoi
@ 2004-08-13  7:14 ` Andrew Lunn
  2004-08-13  9:56   ` kbchoi
  2004-08-20  2:18   ` [ECOS] Questions about cpuload package and cpuload calibration kbchoi
  0 siblings, 2 replies; 6+ messages in thread
From: Andrew Lunn @ 2004-08-13  7:14 UTC (permalink / raw)
  To: kbchoi; +Cc: ecos-discuss

On Fri, Aug 13, 2004 at 01:19:55PM +0900, kbchoi wrote:
> Hello..
> 
>     I'm using the sample "cpuload" packages in "/ecos/packages/services".
> cyg_cpuload_calibrate( ) which is in the first part of test program is using idle thread.
> As I know in "idle thread", the value of idle_thread_loops is increasing continuously.
> Because I want to know the action of idle thread, I modified the cyg_cpuload_calibrate( ) as following.
> 
> cyg_cpuload_calibrate(cyg_uint32  *calibration)
> {
>    cyg_handle_t counter;
>    cyg_alarm alarm_s;
>    cyg_handle_t alarmH;
>    cyg_handle_t idleH;
>    cyg_uint32 idle_loops_start;
>    cyg_priority_t old_priority, cur_priority;
>    int   i,j;
> 
>    cyg_thread_create(1,
>        idle_thread_main,
>        0,
>        "Calibration idle thread",
>        idle_stack,
>        sizeof(idle_stack),
>        &idleH,
>        &thread);
> 
>    xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
>    for (i = 0 ; i < 100000 ; i++)
>       j = i;	// useless work..
>    xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
>    cyg_thread_delay(100);
>    xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
> }
> 
> And the result of this code is following.
> 
> 	cyg_cpuload_calibrate #1 : idle_thread_loops = 0
> 	cyg_cpuload_calibrate #2 : idle_thread_loops = 0
> 	cyg_cpuload_calibrate #3 : idle_thread_loops = 512bc
> 
> Then is idle thread working without cyg_thread_resume( ) ?

Remember this is a real idle thread in the system and that one is
started automatically. Its that idle thread that is incrementing the
loop counter.

        Andrew


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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [ECOS] Questions about cpuload package and idle thread.
  2004-08-13  7:14 ` Andrew Lunn
@ 2004-08-13  9:56   ` kbchoi
  2004-08-13 11:07     ` Andrew Lunn
  2004-08-20  2:18   ` [ECOS] Questions about cpuload package and cpuload calibration kbchoi
  1 sibling, 1 reply; 6+ messages in thread
From: kbchoi @ 2004-08-13  9:56 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: ecos-discuss

Thank you, Andrew.

  Then, after creation of idle_thread in cyg_cpuload_calibrate( ) such asfollowing code,
are two other idle threads running on system?
I still don't understand why idle thread is explicitly started in cyg_cpuload_calibrate( ),
even though idle thread is already running automatically by system.
In my example, there are 3 running threads which are two idle threads(one is started automatically
by system, and the other is started explicitly by my example) and one test thread which runs
this cyg_cpuload_calibrate ( ) function.
Then I don't understand why 2nd value of idle_thread_loops is 0. Is it a condition not to take place
thread switch? Without cyg_thread_delay( ), idle thread cannot be run?

If possible, please give me answers.
Thanks in advance.
			KBCHOI

------------------------------------------------------------------------------------------------------
 cyg_cpuload_calibrate(cyg_uint32  *calibration)
 {
    cyg_handle_t counter;
    cyg_alarm alarm_s;
    cyg_handle_t alarmH;
    cyg_handle_t idleH;
    cyg_uint32 idle_loops_start;
    cyg_priority_t old_priority, cur_priority;
    int   i,j;
 
    cyg_thread_create(1,
        idle_thread_main,
        0,
        "Calibration idle thread",
        idle_stack,
        sizeof(idle_stack),
        &idleH,
        &thread);
 
    xc_printf("cyg_cpuload_calibrate #1 : idle_thread_loops = %x \n", idle_thread_loops);
    for (i = 0 ; i < 100000 ; i++)
       j = i;	// useless work..
    xc_printf("cyg_cpuload_calibrate #2 : idle_thread_loops = %x \n", idle_thread_loops);
    cyg_thread_delay(100);
    xc_printf("cyg_cpuload_calibrate #3 : idle_thread_loops = %x \n", idle_thread_loops);
 }
 
And the result of this code is following.
 
 	cyg_cpuload_calibrate #1 : idle_thread_loops = 0
 	cyg_cpuload_calibrate #2 : idle_thread_loops = 0
 	cyg_cpuload_calibrate #3 : idle_thread_loops = 512bc
 
------------------------------------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [ECOS] Questions about cpuload package and idle thread.
  2004-08-13  9:56   ` kbchoi
@ 2004-08-13 11:07     ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2004-08-13 11:07 UTC (permalink / raw)
  To: kbchoi; +Cc: Andrew Lunn, ecos-discuss

On Fri, Aug 13, 2004 at 06:56:02PM +0900, kbchoi wrote:
> Thank you, Andrew.
> 

>   Then, after creation of idle_thread in cyg_cpuload_calibrate( )
> such asfollowing code, are two other idle threads running on system?
> I still don't understand why idle thread is explicitly started in
> cyg_cpuload_calibrate( ), even though idle thread is already running
> automatically by system.

Let me explain how the calibration function works. Maybe from that you
can work out what your problem is.

The system idle thread runs at the lowest priority. So it only runs
when there is nothing else to do. To calibrate i need the idle thread
to run for a known period of time. To do this i create a second idle
thread. I run this second idle thread at the highest priority eCos
supports. So when the thread is resumed it runs and hopefully no other
thread can run. I have a timer which after 100ms fires. This suspends
my idle thread. From this i can work out how much idle_thread_loop
increments very 100ms for an idle system.

Priorities and multitasking are the important concepts here.

        Andrew

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ECOS] Questions about cpuload package and cpuload calibration
  2004-08-13  7:14 ` Andrew Lunn
  2004-08-13  9:56   ` kbchoi
@ 2004-08-20  2:18   ` kbchoi
  2004-08-20  7:03     ` [ECOS] " Andrew Lunn
  1 sibling, 1 reply; 6+ messages in thread
From: kbchoi @ 2004-08-20  2:18 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: ecos-discuss


Dear Andrew
Hello.

I think I understood what you've explained about the cyg_cpuload_calibrate().
But in the do_test(), the value of calibration is always "0".
I'm using following codes to test cpuload & cpuload calibration.
Please check and reply to me.
Thanks in advance.

		KBCHOI

----- Code in testing ---------------------
void cyg_user_start(void)
{
   static char stack[CYGNUM_HAL_STACK_SIZE_MINIMUM];
   static cyg_handle_t handle;
   static cyg_thread thread;

   enable_int(0);
   lo_init();

   CYG_TEST_INIT();
   cyg_thread_create(4,do_test,0,"cpuload",
                    stack,sizeof(stack),&handle,&thread);
   cyg_thread_resume(handle);
   cyg_scheduler_start();
}



void do_test(cyg_addrword_t data)
{
   cyg_uint32  calibration;
   cyg_cpuload_t  cpuload;
   cyg_handle_t   handle;
   cyg_uint32  average_point1s;
   cyg_uint32  average_1s;
   cyg_uint32  average_10s;
   cyg_uint32  i, j, k = 0;

   CYG_TEST_INFO("About to calibrate cpuload");
   cyg_cpuload_calibrate(&calibration);
   xc_printf("calibration = %x \n", calibration);

   CYG_TEST_INFO("Performing 100% load test");
   cyg_cpuload_create(&cpuload, calibration, &handle);

}


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ECOS] Re: Questions about cpuload package and cpuload calibration
  2004-08-20  2:18   ` [ECOS] Questions about cpuload package and cpuload calibration kbchoi
@ 2004-08-20  7:03     ` Andrew Lunn
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Lunn @ 2004-08-20  7:03 UTC (permalink / raw)
  To: kbchoi; +Cc: Andrew Lunn, ecos-discuss

On Fri, Aug 20, 2004 at 11:17:57AM +0900, kbchoi wrote:
> 
> Dear Andrew
> Hello.
> 
> I think I understood what you've explained about the cyg_cpuload_calibrate().
> But in the do_test(), the value of calibration is always "0".
> I'm using following codes to test cpuload & cpuload calibration.

The code looks OK.

What does the official test do? Does it work?

        Andrew

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-08-20  7:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-13  4:20 [ECOS] Questions about cpuload package and idle thread kbchoi
2004-08-13  7:14 ` Andrew Lunn
2004-08-13  9:56   ` kbchoi
2004-08-13 11:07     ` Andrew Lunn
2004-08-20  2:18   ` [ECOS] Questions about cpuload package and cpuload calibration kbchoi
2004-08-20  7:03     ` [ECOS] " Andrew Lunn

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).