public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* RE: [ECOS] Thread error with large buffer
@ 2001-07-19 15:59 Dan Conti
  2001-07-20  7:43 ` Trenton D. Adams
  0 siblings, 1 reply; 12+ messages in thread
From: Dan Conti @ 2001-07-19 15:59 UTC (permalink / raw)
  To: eCos mailing list

4k is a lot of data to put on a stack. also note that you have 4000
bytes, not 4k there.

why not just make it static? also there are routines you can use to
check the stack size and usage for a given thread. also you can adjust
the stack size for main (the default in a kernel i just glanced at is
8k). also you can enable stack overflow checking.

-Dan

> -----Original Message-----
> From: Trenton D. Adams [ mailto:tadams@extremeeng.com ]
> Sent: Thursday, July 19, 2001 3:18 PM
> To: 'eCos mailing list'
> Subject: [ECOS] Thread error with large buffer
> 
> 
> I'm doing some network tests to test the things some of us 
> were talking
> about before with send sending everything before returning.  I get the
> output below.
> 
> Transfer rate: 656912 bits/sec, 306 bytes/write.
> TRACE: <4>[88]int main() This is the system-supplied default main()
> TRACE: <4>[107]void cyg_libc_invoke_main() main() has 
> returned with code
> 0. Calling exit()
> TRACE: <4>[84]void exit() Calling fflush( NULL )
> Start socket test
> ASSERT FAIL: <2>[166]static void 
> Cyg_Scheduler::unlock_inner() Bad next
> thread
> 
> 
> Below is the thread.  It doesn't give the error above if the buffer
> variable is 400.  Anyone have any ideas why this might be?  Surely a
> static buffer of 4K is not un-reasonable?
> net_test(cyg_addrword_t param)
> {
>     int s;
>     int one = 1;
>     int index;
>     struct sockaddr_in addr;
> 
>     char buffer[4000];
> 
>     buffer[0] = '\0';
> 
>     diag_printf("Start socket test\n");
>     init_all_network_interfaces();
> 
>     for (index = 0; index < 78; index++)
>     {
>         strcat (buffer, 
>             "Hello From eCos! Hello From eCos! Hello From eCos!\n");
>     }
> 
> 
>     s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
>     diag_printf("socket() = %d\n", s);
> 
>     diag_printf ("%x", inet_addr ("172.16.1.9"));
>     addr.sin_addr.s_addr = inet_addr ("172.16.1.9");
>     addr.sin_family = AF_INET;
>     addr.sin_port = htons (1024);
>     addr.sin_len = sizeof (addr);
>     if (connect (s, &addr, sizeof (addr)) != 0)
>     {
>         diag_printf ("Error connecting to socket! - %d\n", 
>             errno);
>         cyg_test_exit();
>     }
> 
>     if (send (s, buffer, strlen (buffer), 0) != 0)
>     {
>         diag_printf ("Error sending to socket! - %d\n", 
>             errno);
>         cyg_test_exit();
>     }
>         
> 
>     cyg_test_exit();
> }
> 
> Trenton D. Adams
> Embedded Developer
> Windows Developer
> Extreme Engineering Ltd.
> Calgary Alberta.
> 
> 
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [ECOS] Thread error with large buffer
@ 2001-07-19 15:18 Trenton D. Adams
  2001-07-19 16:00 ` Gary Thomas
  0 siblings, 1 reply; 12+ messages in thread
From: Trenton D. Adams @ 2001-07-19 15:18 UTC (permalink / raw)
  To: 'eCos mailing list'

I'm doing some network tests to test the things some of us were talking
about before with send sending everything before returning.  I get the
output below.

Transfer rate: 656912 bits/sec, 306 bytes/write.
TRACE: <4>[88]int main() This is the system-supplied default main()
TRACE: <4>[107]void cyg_libc_invoke_main() main() has returned with code
0. Calling exit()
TRACE: <4>[84]void exit() Calling fflush( NULL )
Start socket test
ASSERT FAIL: <2>[166]static void Cyg_Scheduler::unlock_inner() Bad next
thread


Below is the thread.  It doesn't give the error above if the buffer
variable is 400.  Anyone have any ideas why this might be?  Surely a
static buffer of 4K is not un-reasonable?
net_test(cyg_addrword_t param)
{
    int s;
    int one = 1;
    int index;
    struct sockaddr_in addr;

    char buffer[4000];

    buffer[0] = '\0';

    diag_printf("Start socket test\n");
    init_all_network_interfaces();

    for (index = 0; index < 78; index++)
    {
        strcat (buffer, 
            "Hello From eCos! Hello From eCos! Hello From eCos!\n");
    }


    s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    diag_printf("socket() = %d\n", s);

    diag_printf ("%x", inet_addr ("172.16.1.9"));
    addr.sin_addr.s_addr = inet_addr ("172.16.1.9");
    addr.sin_family = AF_INET;
    addr.sin_port = htons (1024);
    addr.sin_len = sizeof (addr);
    if (connect (s, &addr, sizeof (addr)) != 0)
    {
        diag_printf ("Error connecting to socket! - %d\n", 
            errno);
        cyg_test_exit();
    }

    if (send (s, buffer, strlen (buffer), 0) != 0)
    {
        diag_printf ("Error sending to socket! - %d\n", 
            errno);
        cyg_test_exit();
    }
        

    cyg_test_exit();
}

Trenton D. Adams
Embedded Developer
Windows Developer
Extreme Engineering Ltd.
Calgary Alberta.



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2001-07-20  9:05 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-19 15:59 [ECOS] Thread error with large buffer Dan Conti
2001-07-20  7:43 ` Trenton D. Adams
2001-07-20  8:16   ` Gary Thomas
2001-07-20  8:18     ` Trenton D. Adams
2001-07-20  8:31       ` Gary Thomas
2001-07-20  8:40         ` Trenton D. Adams
2001-07-20  8:51           ` Gary Thomas
2001-07-20  8:58             ` Trenton D. Adams
2001-07-20  9:05               ` Gary Thomas
  -- strict thread matches above, loose matches on Subject: below --
2001-07-19 15:18 Trenton D. Adams
2001-07-19 16:00 ` Gary Thomas
2001-07-20  7:28   ` Trenton D. Adams

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).