SimpleIDE Question
ajward
Posts: 1,130
Hi All...
I have a question and I apologize if it's a dumb one!
I'm working my way through some of the C programming tutorials, specifically multicore exmples.:
In the line... void adder(void *par);... what does "*par" do. I've found that it's a read only register and I =think= it points to the location of the "adder" function, but as with many things, I'm probably completely wrong. Any wisdom would be greatly appreciated! (I'm trying to put several of the cores of the Activity Board to use on my Boe Bot)
Amanda
I have a question and I apologize if it's a dumb one!
I'm working my way through some of the C programming tutorials, specifically multicore exmples.:
/* Multicore Example.c Launch a function into another cog (processor) and display what it does to the global n variable over time. */ #include "simpletools.h" // Include simpletools void adder(void *par); // Forward declaration static volatile int t, n; // Global vars for cogs to share unsigned int stack[40 + 25]; // Stack vars for other cog int main() // main function { t = 50; // Set values of t & n n = 5000; // Launch adder function into another cog (processor). cogstart(&adder, NULL, stack, sizeof(stack)); // Watch what the other cog is doing to the value of n. while(1) { print("n = %d\n", n); // Display result pause(100); // Wait 1/10 of a second } } // Function that can continue on its // own if launched into another cog. void adder(void *par) // adder keeps going on its own { while(1) // Endless loop { n = n + 1; // n + 1 each time loop repeats pause(t); // Wait for t ms between updates } }
In the line... void adder(void *par);... what does "*par" do. I've found that it's a read only register and I =think= it points to the location of the "adder" function, but as with many things, I'm probably completely wrong. Any wisdom would be greatly appreciated! (I'm trying to put several of the cores of the Activity Board to use on my Boe Bot)
Amanda
Comments
EDIT: jazzed beat me to it
Amanda