PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Multicore
Cog Stack Usage Test.c
1
/*
2
Cog Stack Usage Test.c
3
4
Test how many int variables the cog actually used.
5
6
http://learn.parallax.com/multicore-approaches
7
*/
8
9
#include "
simpletools.h
"
// Library includes
10
#include "
stacktest.h
"
11
12
void
myCog();
// Function prototype
13
int
*cog;
// Cog process ID variable
14
15
volatile
int
elements = 20;
// Elements for cog's array
16
17
int
main
()
// Main function
18
{
19
cog =
cog_runStackTest
(myCog, 512);
// Run the cog test
20
print
(
"Please wait 2 seconds...\n"
);
// User prompt
21
pause
(2000);
// Give time to put cog to work
22
int
stacksize =
cog_endStackTest
(cog);
// Get the result
23
print
(
"Stack int usage = %d.\n"
,
// Display result
24
stacksize);
25
}
26
27
void
myCog()
// Function running in other cog
28
{
29
int
array[elements];
// Declare an array
30
int
n = 0;
// Initialize counting variable
31
while
(1)
// Function's loop
32
{
33
array[n % elements] = n++;
// Add 1 to array cell, add 1 to n
34
pause
(10);
// Wait 10 ms before repeat
35
}
36
}
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
print
int print(const char *format,...) __attribute__((format(printf
Print format "..." args to the default simple terminal device. The output is limited to 256 bytes.
main
int main(void)
Definition:
GraphicsTest.c:20
cog_endStackTest
int cog_endStackTest(int *coginfo)
Ends function code running in another cog that was launched by cog_runStackTest and returns the numbe...
Definition:
cogendStackTest.c:17
stacktest.h
Provides a tool for testing how much of a cog's stack has been used.
cog_runStackTest
int * cog_runStackTest(void(*function)(void *par), int stacksize)
Runs a function's code in the next available cog (processor) and tracks how much of the call stack th...
Definition:
cogrunStackTest.c:18
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17