Hi,
I am trying to pass parameters to queued jobs and have the jobs print out the parameter which was passed to them at the bottom of this email is one of my attempts at it.
Every other parameter is printed out as 2097334. I seem to be doing something wrong but cannot figure out what it is.
The output I am getting is as follows:
3
2097334
2
2097334
8
Jobs completed. Terminating
Also, shouldn't b_smp_run() accept a var parameter?
What I am eventually aiming to have is a shared array of buffers and a job which does some work on a buffer. Whenever something comes in over the nic interface a free buffer is populated with the b_ethernet_rx() call
and the index of the buffer is queued with the job to be picked up later by a processor.
Thanks
David
======================================================================================================================================
int main(void)
{
unsigned long j, local = 0;
unsigned long numArr[5] = {3, 4, 2, 5, 8};
for(j = 0; j <5; j++)
{
b_smp_enqueue(&sample_process, numArr[j]);
}
while (b_smp_queuelen() != 0) // Check the length of the queue. If greater than 0 then try to run a queued job.
{
unsigned long tvar;
local = b_smp_dequeue( &tvar ); // Grab a job from the queue. b_smp_dequeue returns the memory address of the code
if (local != 0) // If it was set to 0 then the queue was empty
b_smp_run(local); // Run the code
}
b_smp_wait();
b_print_string("Jobs completed. Terminating\n");
return 0;
}
void sample_process(unsigned long incrVal)
{
unsigned char NumAsStr[10];
b_int_to_string(incrVal, NumAsStr);
b_print_string(NumAsStr);
b_print_newline();
// wait 1 second
b_delay(8);
}