This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RE: Questions about cpuload package and idle thread.
- From: "kbchoi" <kbchoi at snssol dot co dot kr>
- To: "Andrew Lunn" <andrew at lunn dot ch>
- Cc: <ecos-discuss at ecos dot sourceware dot org>
- Date: Fri, 13 Aug 2004 18:56:02 +0900
- Subject: RE: [ECOS] Questions about cpuload package and idle thread.
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
------------------------------------------------------------------------------------------------------