blackrabbit
Legacy Member
Gegeven de volgende functie die door een pThread wordt uitgevoerd:
Uitvoer van het programma:
Als nu in bovenstaande code die 'prinf(".");' uit commentaar wordt gehaald, veranderd de uitvoer naar dit:
Er wordt nu duidelijk méér code uitgevoerd, maar de vraag is: waarom? Die printf zou er toch niet mogen toe doen??
Code:
void *SpeManager::spe_instructions_pthread_function(void * arg)
{
//init some variables
//...
printf("Running SPE mailbox checker for SPE %u\n",spe.id);
SpeManager* speManager=(SpeManager*)(args->speManager);
speInstructionQueue* q = speManager->getSpeQueue(spe);
//...
unsigned int *instructions;
printf("----- SPE-MANAGER check 1: %u\n",speManager->check());
while(true)
{
//printf(".");//DEZE HIER
if(q->size()!=0)
{
printf("Size is now: %i\n",q->size());
SPE_instruction instr = q->front();
//remove from queue
q->pop();
//process
switch(instr.arg_count)
{
case 0:
//do stuff
break;
case 1:
//do stuff
break;
case 2:
//do stuff
break;
case 3:
//do stuff
break;
default:
printf("def\n");
//do other stuff
break;
}
while(!speManager->SPE_mailbox_empty(spe))
{
//do nothing (busy wait)
printf("not empty (SPE %i)\n",spe.id);
}
if(size!=0)
{
printf("Sending to mailbox of spe %i, size %i\n",spe.id,size);
delete instructions;
}
}
//printf(",");
}
return NULL;
}
Uitvoer van het programma:
Code:
[bartmaes@soft30 t2]$ ./t1
Creating new SpeManager with 1 SPE cores
[B]Running SPE mailbox checker for SPE 0[/B]
[B]----- SPE-MANAGER check 1: 951357[/B]
Running SPE program for SPE 0
(SPE) SPE STARTED
Required number of buffers: 2
Queue-size: 2
(PPU) SPE_instruct(0,1,0xffb09700,64)
(PPU) enqueued instruction: 5 with id 4
(PPU) double check: 5
(PPU) Enqueuing instruction 5 for SPE 0, queue now has size 1
(PPU) SPE_instruct(0,1,0xffb09800,64)
(PPU) enqueued instruction: 9 with id 8
(PPU) double check: 9
(PPU) Enqueuing instruction 9 for SPE 0, queue now has size 2
Code:
Creating new SpeManager with 1 SPE cores
[B]Running SPE mailbox checker for SPE 0[/B]
[B]----- SPE-MANAGER check 1: 951357[/B]
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
................................
Running SPE program for SPE 0
............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
(SPE) SPE STARTED
........................................................................................................................................................
Required number of buffers: 2
Queue-size: 2
(PPU) SPE_instruct(0,1,0xffcad700,64)
(PPU) enqueued instruction: 5 with id 4
.(PPU) double check: 5
..(PPU) Enqueuing instruction 5 for SPE 0, queue now has size 1
(PPU) SPE_instruct(0,1,0xffcad800,64)
(PPU) enqueued instruction: 9 with id 8
(PPU) double check: 9
Size is now: 1
(PPU) Enqueuing instruction 9 for SPE 0, queue now has size 2
Found enqueued instruction for SPE 0
Sending to mailbox of spe 0, size 3
.Size is now: 1
Found enqueued instruction for SPE 0
[B]SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)[/B]
[B](SPE) Fetching instruction
SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)[/B]
[B](SPE) original instruction: 5, filtered instr: 1, mask: 3
SPE-inbox not empty (SPE 0)
SPE-inbox not empty (SPE 0)
instruction from mbox: 5, filtered: 1
SPE-inbox not empty (SPE 0)
(SPE) instruction_instr: 1 SPE-inbox not empty (SPE 0)
blockAdress: 0xffcad700,size 64
Sending to mailbox of spe 0, size 3[/B]
INFO: fetched instruction: 5
...............................................................................................
(SPE) original instruction: 5, filtered instr: 1, mask: 3
......................................................................
(SPE) original instruction: 5, filtered instr: 1, mask: 3
.....................................................................
(SPE) original instruction: 5, filtered instr: 1, mask: 3
.....................................................................
(SPE) original instruction: 5, filtered instr: 1, mask: 3
...........................................................................
(SPE) (successfully fetched correct instruction from mailbox, instruction enqueued for processing) INFO: id: 1, instr: 1
......................................................
(SPE) Fetching instruction
........................................................................................
(SPE) original instruction: 9, filtered instr: 1, mask: 3
................................................................
instruction from mbox: 9, filtered: 1
.............................................................
(SPE) instruction_instr: 1
................................................................
blockAdress: 0xffcad800,size 64
.............................................................
INFO: fetched instruction: 9
.....................................................................
(SPE) original instruction: 9, filtered instr: 1, mask: 3
......................................................................
(SPE) original instruction: 9, filtered instr: 1, mask: 3
......................................................................
(SPE) original instruction: 9, filtered instr: 1, mask: 3
......................................................................
(SPE) original instruction: 9, filtered instr: 1, mask: 3
.........................................................................
(SPE) (successfully fetched correct instruction from mailbox, instruction enqueued for processing) INFO: id: 1, instr: 1
........................................................
Er wordt nu duidelijk méér code uitgevoerd, maar de vraag is: waarom? Die printf zou er toch niet mogen toe doen??
.