Here is my code then you can see it all.
#include <stdio.h># include <unistd.h># include <stdlib.h># include <pthread.h>
void *print_message_function( void *ptr );
int main()
{
printf("NIOS II says hello\n");
int *arrayBuffer;
for(int x=0; x < 10; x++)
{
arrayBuffer = new int;
printf("*\n");
}
//pthread_t tmp;
//pthread_t thread2;
char *message1 = "Thread 1"; printf("2\n");
char *message2 = "Thread 2";
int iret1, iret2;
printf("#\n");
/* Create independant threads each of which will execute function */
//iret1 = pthread_create( &tmp, NULL, print_message_function, (void*) message1);
//iret2 = pthread_create( &thread2, NULL, print_message_function, (void*) message2);
/* Wait till threads are complete before main continues. Unless we */
/* wait we run the risk of executing an exit which will terminate */
/* the process and all threads before the threads have completed. */
//pthread_join( thread1, NULL);
//pthread_join( thread2, NULL);
printf("Thread 1 returns: %d\n",iret1);
printf("Thread 2 returns: %d\n",iret2);
return 1;
}
void *print_message_function( void *ptr )
{
printf("***\n");
char *message;
message = (char *) ptr;
while(1)
{
printf("%s \n", message);
usleep(1000000);
}
}
When I create the arrayBuffer the kernel panics. The IDE does not allow debugging of this app since it's a app in the filesystem of the kernel. Normally I would just debug it I find the error this way.
If I don't create the array the kernel runs just fine.
Hope that this clarifies your question.
Regards
GreateWhite.DK