Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12748 Discussions

Application freezes using Posix thread

Altera_Forum
Honored Contributor II
1,502 Views

I have a medium-sized project that creates threads. Really weird problem is, after the pthread_create(), the console freezes. I dont know what the problem is. 

 

I tried commenting everything out, and just left with pthread_create, the problem disappeared. 

 

I also have a smaller project that uses the same makefile, and the threads are created fine. 

 

I set my stack size to be  

 

FLTFLAGS := -s 2000000 

 

...I'm not sure what the problem is. Anyone has a suggestion? 

 

Thanks
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
389 Views

Also, to note: if the project doesn't call pthread_create(), the project runs fine. I wanted to use thread to handle external events (interrupts, DMA in the background, etc)

0 Kudos
Altera_Forum
Honored Contributor II
389 Views

Forgot to mention that my environment is uCLinux on Nios-II processor.

0 Kudos
Altera_Forum
Honored Contributor II
389 Views

Problem solved. The reason was because I allocated too many big local variables. Each of those local variables was a data structure. All of them add up to be about 7331 bytes. I fixed this problem by using malloc() to create those variables instead.  

 

At first, my program's size was about 4000K when I did a "ps" command, but now it dropped down to 2000K. so, it's all good now. No more hangups when I call pthread_create().
0 Kudos
Reply