T
Tobias Baumann
Guest
Hi
I want to handle an array with some hundred elements.
Here is an example code:
#include "xmk.h"
#include "sys/init.h"
#include "platform.h"
#include "xbasic_types.h"
#include <stdio.h>
#define BUFFER_LENGTH 496
void printBuffer(Xuint8* buffer, Xuint16 length)
{
Xuint16 i = 0;
for(i=0; i<length; i++) {
printf("buffer %u: %x\r\n", i, buffer);
}
return;
}
void *hello_world(void *arg)
{
Xuint32 i = 0;
Xuint8 buffer[BUFFER_LENGTH];
for(i=0; i<BUFFER_LENGTH; i++) {
buffer = 0xAA;
}
printBuffer(buffer, BUFFER_LENGTH);
print("Hello World\r\n");
return 0;
}
int main()
{
init_platform();
/* Initialize xilkernel */
xilkernel_init();
/* add a thread to be launched once xilkernel starts */
xmk_add_static_thread(hello_world, 0);
/* start xilkernel - does not return control */
xilkernel_start();
/* Never reached */
cleanup_platform();
return 0;
}
The maximum buffer length can be 496. If I increase the heap and stack
size from 1kB to 2kB, the maximum buffer length can be 772. It's a bit
weired, because I double the stack size, but I can't double the array
size. In an other programm I have a stack and heap size of 20MB and I
only can create an array with 256 elements.
So I need some basical information about where I have to find mistakes
in my program and how I can solve them. And I need information about
where the limits are. For example when I increase the stack size so 1000
kB, the program above won't run with an 5000 elements array. I have no
idea where the problem is and where I have to search.
Thanks a lot for helping.
Greets,
Tobias
I want to handle an array with some hundred elements.
Here is an example code:
#include "xmk.h"
#include "sys/init.h"
#include "platform.h"
#include "xbasic_types.h"
#include <stdio.h>
#define BUFFER_LENGTH 496
void printBuffer(Xuint8* buffer, Xuint16 length)
{
Xuint16 i = 0;
for(i=0; i<length; i++) {
printf("buffer %u: %x\r\n", i, buffer);
}
return;
}
void *hello_world(void *arg)
{
Xuint32 i = 0;
Xuint8 buffer[BUFFER_LENGTH];
for(i=0; i<BUFFER_LENGTH; i++) {
buffer = 0xAA;
}
printBuffer(buffer, BUFFER_LENGTH);
print("Hello World\r\n");
return 0;
}
int main()
{
init_platform();
/* Initialize xilkernel */
xilkernel_init();
/* add a thread to be launched once xilkernel starts */
xmk_add_static_thread(hello_world, 0);
/* start xilkernel - does not return control */
xilkernel_start();
/* Never reached */
cleanup_platform();
return 0;
}
The maximum buffer length can be 496. If I increase the heap and stack
size from 1kB to 2kB, the maximum buffer length can be 772. It's a bit
weired, because I double the stack size, but I can't double the array
size. In an other programm I have a stack and heap size of 20MB and I
only can create an array with 256 elements.
So I need some basical information about where I have to find mistakes
in my program and how I can solve them. And I need information about
where the limits are. For example when I increase the stack size so 1000
kB, the program above won't run with an 5000 elements array. I have no
idea where the problem is and where I have to search.
Thanks a lot for helping.
Greets,
Tobias