On Mon, Sep 10, 2007 at 07:38:04PM +0800, [EMAIL PROTECTED] 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
