This is the mail archive of the ecos-discuss@sourceware.org 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]

Re: strange behavior with single thread


Just to add to the rest of the info, I'm using i386-elf (that comes
with ecos) to compile my
program.

I have another program that too has a single thread and it uses TWO
struct sockaddr_in var's.
That program works just fine!

Running strace on the prog shows a lot of Seg faults happening. I'm
pretty clueless right now
as to why one works while the other does not! :(

-mandeep

On Mon, Aug 3, 2009 at 2:53 PM, Mandeep
Sandhu<mandeepsandhu.chd@gmail.com> wrote:
> Hi All,
>
> I have a _very_ simple thread app which I've modified from the
> "twothreads.c" example.
>
> It does nothing except start a thread in which I simply print a debug
> message and declare
> a var of "struct sockaddr_in". But on starting the app, it stops after a call to
> cyg_thread_resume(), i.e the thread does not start!
>
> I had originally written a limited DHCP server implementation (which
> was not working)!
> So on debugging I narrowed down the problem to a declaration of
> "struct sockaddr_in"
> variable.
>
> So I thought I'd make a simple thread which just declares this var and
> does nothing. And
> even in this sample app (test.c) I saw the same problem. I've
> allocated a big enough stack
> for the thread - 4KB. Also, increasing the stack size does not help.
> The source is pasted
> below.
>
> I know this is only some minor oversight from my side, but any
> pointers will be very helpful
>
> Thanks,
> -mandeep
>
> test.c:
>
> #include <cyg/kernel/kapi.h>
> #include <network.h>
>
> cyg_thread test_s;
> cyg_handle_t test_thread;
> cyg_thread_entry_t test_start;
> char stack[4096];
>
>
> void test_start(cyg_addrword_t data)
> {
> ? ?diag_printf("TEST!\n");
> ? ?struct sockaddr_in addr;
> ? ?cyg_test_exit();
> }
>
> void cyg_user_start(void)
> {
> ? ?diag_printf("Configuring test thread...\n");
> ? ?cyg_thread_create( 4,
> ? ? ? ? ? ? ? ? ? ? ? test_start,
> ? ? ? ? ? ? ? ? ? ? ? (cyg_addrword_t) 0,
> ? ? ? ? ? ? ? ? ? ? ? "TEST Thread",
> ? ? ? ? ? ? ? ? ? ? ? (void *) &stack,
> ? ? ? ? ? ? ? ? ? ? ? 4096,
> ? ? ? ? ? ? ? ? ? ? ? &test_thread,
> ? ? ? ? ? ? ? ? ? ? ? &test_s );
>
>
> ? ?diag_printf("Starting test...\n");
> ? ?cyg_thread_resume(test_thread);
> }
>

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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