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]

Re: Re: strange behavior with single thread [FIXED]

Mandeep Sandhu wrote:
False alarm people.

My Makefile was screwed up! I had the .cc target defined (copy-paste
of which it was using "CC" to compile my program and using i386-elf to link it.

I guess this explains the weired behavior!

Sorry if I wasted anybody's time! :P


On Mon, Aug 3, 2009 at 4:42 PM, Mandeep
Sandhu<> wrote:
Just to add to the rest of the info, I'm using i386-elf (that comes
with ecos) to compile my

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! :(


On Mon, Aug 3, 2009 at 2:53 PM, Mandeep
Sandhu<> 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"

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

I know this is only some minor oversight from my side, but any
pointers will be very helpful



#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,
                      (cyg_addrword_t) 0,
                      "TEST Thread",
                      (void *) &stack,
                      &test_s );

diag_printf("Starting test...\n"); cyg_thread_resume(test_thread); }

Yes, I too ran into that problem, and floundered until I realized that cyg_user_start *must* be a "C" symbol as it's called from C code.


-- 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]