This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: A problem about constructor sequence
- From: taiyun at sunnorth dot com dot cn
- To: Andrew Lunn <andrew at lunn dot ch>
- Cc: ecos-discuss at ecos dot sourceware dot org, Jonathan Larmour <jifl at ecoscentric dot com>, taiyun at sunnorth dot com dot cn
- Date: Mon, 10 Sep 2007 19:46:34 +0800
- Subject: Re: [ECOS] A problem about constructor sequence
- Sensitivity:
>I don't see how this can break anything. The scheduler is disabled at
>this point anyway. The the resume call just marks the thread as
>runable, but it won't get run until a lot later.
>Jifl: Is this O.K?
Thanks a lot, really appreciate your answers.
But I still doubt, I have checked the source code of thread.cxx, I found
that thread's state is set to SUSPENDED in Cyg_Thread class's constructor
and suspend_count variable is set to 1(1 represents suspended and 0
represents ready or running, right?), so when Cyg_Thread's resume method is
called, suspend_count will be set to 0 to indicate this thread is not
suspended, and state of thread will be set, too.
cyg_libc_main_thread is an instance of Cyg_Thread, so it must follow this
procedure. If it was constructed first, then when instance
cyg_libc_startup_obj is constructed, cyg_libc_main_thread.resume will be
called.
BUT if cyg_libc_main_thread is constructed after cyg_libc_startup_obj, I
think this case will cause problem. Because cyg_libc_startup_obj will call
cyg_libc_main_thread.resume, NOW I know scheduler is not start yet till
this point, so it just sets some flag, it is ok.
BUT after cyg_libc_startup_obj is constructed, then will be
cyg_libc_main_thread. In constructor of cyg_libc_main_thread, thread's
state will be set to SUSPENDED, and will never be resumed, isn't it?
Can't this cause problem??
Sincerely Yours
***********************************************
Beijing Sunnorth eCos Maintainer Group
Maintainers:
liqin@sunnorth.com.cn
wanghui@sunnorth.com.cn
taiyun@sunnorth.com.cn
yxinghua@sunnorth.com.cn
Bejing Sunnorth Electronic Technology Co.,LTD
***********************************************
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss