Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

Application freezes using Posix thread

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

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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)

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

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