From: Andrew Lunn <andrew@lunn.ch>
To: eCos@sunnorth.com.cn
Cc: Andrew Lunn <andrew@lunn.ch>, ecos-discuss@ecos.sourceware.org
Subject: [ECOS] Re: ????: Re: [ECOS] A problem about constructor sequence
Date: Mon, 10 Sep 2007 12:58:00 -0000 [thread overview]
Message-ID: <20070910125809.GA23980@lunn.ch> (raw)
In-Reply-To: <OFD56A862C.7D2739A1-ON48257352.003F8CFF-48257352.003FE916@sunnorth.com.cn>
On Mon, Sep 10, 2007 at 07:38:04PM +0800, eCos@sunnorth.com.cn wrote:
> >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?
What i said was:
> I think you are correct. Probably the second should be
>
> static cyg_libc_startup_dummy_constructor_class cyg_libc_startup_obj
> CYGBLD_ATTRIB_INIT_AFTER(CYG_INIT_LIBC)
The _AFTER() change means that cyg_libc_startup_obj is constructed
after all other constructors of priority CYG_INIT_LIBC are
called. Thus cyg_libc_main_thread will always be called first.
Or am i missing something 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
next prev parent reply other threads:[~2007-09-10 12:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-10 9:14 taiyun
2007-09-10 9:35 ` Andrew Lunn
2007-09-10 9:54 ` Jonathan Larmour
[not found] ` <OFD56A862C.7D2739A1-ON48257352.003F8CFF-48257352.003FE916@sunnorth.com.cn>
2007-09-10 12:58 ` Andrew Lunn [this message]
2007-09-11 16:48 ` Andrew Lunn
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=20070910125809.GA23980@lunn.ch \
--to=andrew@lunn.ch \
--cc=eCos@sunnorth.com.cn \
--cc=ecos-discuss@ecos.sourceware.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 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).