Topic
  • No replies
ocs7474505
ocs7474505
1 Post

Pinned topic Invalid Machine Code Error Message when Thread ends

‏2010-07-07T09:19:53Z |
Hello.

I'm developing on the Cell (Playstation 3). Now I get an error message I'm not able to relate. The message is "ungültiger Maschinenbefehl" or in english "invalid machine code" (I think). It pops up when a thread finishes. I located it by putting a sleep-command of 5 seconds before the spawning of a thread (4 threads should be spawned). Then the SPU program runs properly, finishes and at the moment the main-method in the SPU finishes (= return 0) the error pops up after only a few milliseconds.
The same program runs properly when I spawn 5 threads or more. The data amount I send increases by reducing the thread amount. But it fetches the data right from the bus system, even when its bigger than 16K. And it even runs properly. I dont get the relation that it crashes only by finishing the thread. Has anyone any idea? Would be very helpful!

PPU



for (i = 0; i < real_threads; ++i) 
{ thread[i].argp = (void*) addresses; thread[i].envp = (void*) sizeof(addresses);   
/* create context (this represents a single SPE) */ 

if ((thread[i].id = spe_context_create(0, NULL)) == NULL) 
{ perror(
"spe_context_create"); exit(1); 
}   
/* load program into context */ 

if (spe_program_load(thread[i].id, image)) 
{ perror(
"spe_program_load"); exit(1); 
}   
/* put the id of the thread and the number of data per thread in * each mailbox. */ spe_in_mbox_write(thread[i].id, &i, 1, SPE_MBOX_ANY_NONBLOCKING); spe_in_mbox_write(thread[i].id, &number_data_per_thread, 1, SPE_MBOX_ANY_NONBLOCKING);   
/* create thread */ 

if (pthread_create(&thread[i].pthread, NULL, &pthread_function, &thread[i])) 
{ perror(
"pthread_create"); exit(1); 
} printf(
"going to sleep: %u\n", i); sleep(5); printf(
"check\n"); 
// <-- THIS POINT IS NEVER REACHED 
}   
/* finish threads */ 

for (i = 0; i < real_threads; ++i) 
{ 
/* wait for thread to end */ printf(
"%u CHECK\n", i); 

if (pthread_join(thread[i].pthread, NULL)) 
{ perror(
"pthread_join"); exit(1); 
}   
/* destroy context */ 

if (spe_context_destroy(thread[i].id)) 
{ perror(
"spe_context_destroy"); exit(1); 
} 
}


SPU:

... printf(
"done %u\n", id); 

return 0; 
}


Ok there is something happening in the SPU code (where the ... are). When I delete it and only use the SPU code terminate the program (= return 0), it works. But I don't get the relation, the other code seems to work right because it runs to the return. Only when it returns, the program crashes.

Thanks in advance,
best regards,
Oliver