PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Utility
libstacktest
cogstartStackTest.c
1
/*
2
* @file cogstartStackTest.c
3
*
4
* @author Andy Lindsay
5
*
6
* @copyright
7
* Copyright (C) Parallax, Inc. 2014. All Rights MIT Licensed.
8
*
9
* @brief Source code for cog_end function.
10
*
11
* @version 0.50
12
*/
13
14
#include "
stacktest.h
"
15
#include "
simpletools.h
"
16
17
int
cogstart_stackTest
(
void
(*func)(
void
*),
void
*par,
void
*stack,
size_t
stacksize)
18
{
19
int
*addr = (
int
*) stack;
20
21
int
cogRunTestOverhead = 2 *
sizeof
(int);
22
//print("cogRunTestOverhead = %d bytes, %d ints\n", cogRunTestOverhead, cogRunTestOverhead/sizeof(int));
23
int
stackOverhead =
sizeof
(
_thread_state_t
) + (3 *
sizeof
(
unsigned
int
));
24
//print("stackOverhead = %d bytes, %d ints\n", stackOverhead, stackOverhead/sizeof(int));
25
int
stackOther = (stacksize/
sizeof
(int)) - (stackOverhead/
sizeof
(int)) - (cogRunTestOverhead/
sizeof
(int));
26
//print("stackOther = %d ints\n\n", stackOther);
27
srand(stackOther);
28
29
int
n = 0;
30
for
(
int
*i = addr+2; i < ((
int
*)addr + (stacksize/
sizeof
(
int
))); i++)
31
{
32
// *i = n;
33
*i = rand();
34
n++;
35
}
36
37
*addr =
cogstart
(func, par, (
int
*) stack + cogRunTestOverhead/
sizeof
(
int
), stacksize - cogRunTestOverhead);
38
39
//print("\n\n---[ cogstart_stackTest ]--- \n\n");
40
//print("Cog Address = %d, Cog Value = %d\n", (int) addr, *addr);
41
*(addr + 1) = stacksize/
sizeof
(
int
);
42
//print("Stack Count Address = %d, Stack Count = %d\n\n", (int)(addr+1), *(addr+1));
43
// // print("(int)(addr+2) = %d\n", (int)(addr+2));
44
return
*addr;
45
}
46
47
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
_thread
Definition:
thread.h:61
stacktest.h
Provides a tool for testing how much of a cog's stack has been used.
cogstart
int cogstart(void(*func)(void *), void *par, void *stack, size_t stacksize)
Start a new propeller LMM function/thread in another COG.
cogstart_stackTest
int cogstart_stackTest(void(*func)(void *), void *par, void *stack, size_t stacksize)
Starts a function's code in the next available cog (processor) and tracks how much of the call stack ...
Definition:
cogstartStackTest.c:17
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17