This is the mail archive of the mailing list for the eCos project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How to know if the scheduler is already running


I am trying to get an application with a flash file
system running and I am stumbling upon the initialization

My SPI device is using an interrupt mode and this works
in a simple application that does the initialization
in or after cyg_user_start. However, after adding
the dependencies needed for a JFFS2 the cyg_io_init
adds itself to the constructors

#8  0x20820458 in cyg_flash_init (pf=<value optimized out>)
    at /ecos-d/CygwinData/ecos/packages/io/flash/current/src/flash.c:241
#9  0x20811b30 in flashiodev_init (tab=<value optimized out>)
    at /ecos-d/CygwinData/ecos/packages/io/flash/current/src/flashiodev.c:129
#10 0x20815bb8 in cyg_io_init ()
    at /ecos-d/CygwinData/ecos/packages/io/common/current/src/iosys.c:105
#11 0x20814ab8 in cyg_hal_invoke_constructors ()
    at /ecos-d/CygwinData/ecos/packages/hal/arm/arch/current/src/hal_misc.c:213

This results in the code using interrupts and DSR to be
called, the calling code does cyg_drv_cond_wait, the scheduler
tries to switch the context and right after

  HAL_THREAD_SWITCH_CONTEXT( &current->stack_ptr, &next->stack_ptr );

the application crashes

  Program received signal SIGTRAP, Trace/breakpoint trap.
  0x208372dc in cygmem_pool_heap1 ()

To me this looks like I am calling something that should
be called only from a thread context, before the kernel
is initialized.

How can I know in a constructor code, whether it is safe
to call the mutexes/conditions/...? I have no problem to revert
to the polled mode in the startup code, if I know when
it is safe to switch to the interrupt-driven one.


Before posting, please read the FAQ:
and search the list archive:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]