* [ECOS] strange behavior with single thread
@ 2009-08-03 9:23 Mandeep Sandhu
2009-08-03 11:12 ` [ECOS] " Mandeep Sandhu
0 siblings, 1 reply; 2+ messages in thread
From: Mandeep Sandhu @ 2009-08-03 9:23 UTC (permalink / raw)
To: ecos-discuss
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ECOS] Re: strange behavior with single thread
2009-08-03 9:23 [ECOS] strange behavior with single thread Mandeep Sandhu
@ 2009-08-03 11:12 ` Mandeep Sandhu
0 siblings, 0 replies; 2+ messages in thread
From: Mandeep Sandhu @ 2009-08-03 11:12 UTC (permalink / raw)
To: ecos-discuss
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-03 11:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-03 9:23 [ECOS] strange behavior with single thread Mandeep Sandhu
2009-08-03 11:12 ` [ECOS] " Mandeep Sandhu
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).