v0.4.8 should be coming out in the next few weeks. Changes have been made to the multi-processor functions and the C library for the OS now supports the SMP calls as well.
Code: Select all
// BareMetal compile
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o csmp.o csmp.c
// gcc -c -m64 -nostdlib -nostartfiles -nodefaultlibs -fomit-frame-pointer -o libBareMetal.o libBareMetal.c
// ld -T app.ld -o csmp.app csmp.o libBareMetal.o
#include "libBareMetal.h"
void loop_a();
void loop_b();
int main()
{
unsigned long var1=0, var2=0, local=0;
b_smp_enqueue(&loop_a); // Queue up some jobs
b_smp_enqueue(&loop_b); // The BareMetal OS queue is FIFO
b_smp_enqueue(&loop_a);
b_smp_enqueue(&loop_b);
b_smp_enqueue(&loop_a);
b_smp_enqueue(&loop_b);
b_smp_enqueue(&loop_a);
b_smp_enqueue(&loop_b);
while (b_smp_queuelen() != 0) // Check the length of the queue. If greater than 0 then try to run a queued job.
{
local = b_smp_dequeue(); // 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(); // Wait for all CPU cores to finish
b_print_string("end\n");
return 0;
}
void loop_a()
{
register unsigned long j,k;
for(k=0; k<=665555; k++)
{
for(j=0; j<=100; j++){}
}
b_print_string("A is done\n");
}
void loop_b()
{
register unsigned long j,k;
for(k=0; k<=665555; k++)
{
for(j=0; j<=200; j++){}
}
b_print_string("B is done\n");
}
// EOF
-Ian