Hi, Can anybody shed some light onto a problem that I am having getting the xilkernel to behave! Essentially, I compile my simple program and the kernel keeps creating new instances of itself at run time. The prog_main() is set up as a static thread instance PARAMETER static_pthread_table = ((prog_main,1)) in the MSS file. See the ouput below (with verbose debug to true) source ------ #include "xmk.h" #include <stdio.h> void *prog_main(void *arg); int main () { xilkernel_main (); } void *prog_main(void *arg) { static Index = 0; printf("prog_main(%d) called\n\r", Index++); while(1) { printf("In main - Data%d Index:%d\n\r", Data++, Index); sleep(500); } } output ------ In main - Data18 Index:6 In main - Data19 Index:6 Idle Task XMK: Start XMK: Initializing Hardware... XMK: Initializing interrupt controller XMK: Connecting timer interrupt XMK: Starting the interrupt controller XMK: Initializing PIT device. XMK: System initialization... XMK: Enabling interrupts and starting system... prog_main(6) called In main - Data20 Index:7 Idle Task XMK: Start XMK: Initializing Hardware... XMK: Initializing interrupt controller XMK: Connecting timer interrupt XMK: Starting the interrupt controller XMK: Initializing PIT device. XMK: System initialization... XMK: Enabling interrupts and starting system... prog_main(7) called In main - Data21 Index:8 Idle Task In main - Data22 Index:8 In main - Data23 Index:8 In main - Data24 Index:8 In main - Data25 Index: In main - Data1099 Index:407 In main - Data1100 Index:407 XMK: Start XMK: Initializing Hardware... XMK: Initializing interrupt controller XMK: Connecting timer interrupt XMK: Starting the interrupt controller XMK: Initializing PIT device. XMK: System initialization... XMK: Enabling interrupts and starting system... prog_main(407) called In main - Data1101 Index:408 Idle Task In main - Data1102 Index:408 XMK: Start XMK: Initializing Hardware... XMK: Initializing interrupt controller XMK: Connecting timer interrupt XMK: Starting the interrupt controller XMK: Initializing PIT device. XMK: System initialization... XMK: Enabling interrupts and starting system... prog_main(408) called In main - Data1103 Index:409 Idle Task etc!!!!
xilkernel and threads
Started by ●February 7, 2005
Reply by ●February 7, 20052005-02-07
Hi, You are using printf in your threads. printf requires a big stack. There is likely a stack overflow in the thread. You should increase the stack size allocated for threads, or allocate a custom large while creating the thread with pthread_create. Since there is no memory protection, these kind of errors can usually bring the kernel (and any standalone program for that matter) down to its knees. thanks, Vasanth Stef wrote:> Hi, > > Can anybody shed some light onto a problem that I am having getting > the xilkernel to behave! Essentially, I compile my simple program and > the kernel keeps creating new instances of itself at run time. The > prog_main() is set up as a static thread instance PARAMETER > static_pthread_table = ((prog_main,1)) in the MSS file. See the ouput > below (with verbose debug to true) > > source > ------ > > #include "xmk.h" > > #include <stdio.h> > > void *prog_main(void *arg); > > int main () > { > xilkernel_main (); > } > > > void *prog_main(void *arg) > { > static Index = 0; > printf("prog_main(%d) called\n\r", Index++); > > while(1) > { > printf("In main - Data%d Index:%d\n\r", Data++, Index); > sleep(500); > } > } > > > output > ------ > > > In main - Data18 Index:6 > > In main - Data19 Index:6 > Idle Task > XMK: Start > XMK: Initializing Hardware... > XMK: Initializing interrupt controller > XMK: Connecting timer interrupt > XMK: Starting the interrupt controller > XMK: Initializing PIT device. > XMK: System initialization... > XMK: Enabling interrupts and starting system... > > prog_main(6) called > > In main - Data20 Index:7 > Idle Task > XMK: Start > XMK: Initializing Hardware... > XMK: Initializing interrupt controller > XMK: Connecting timer interrupt > XMK: Starting the interrupt controller > XMK: Initializing PIT device. > XMK: System initialization... > XMK: Enabling interrupts and starting system... > > prog_main(7) called > > In main - Data21 Index:8 > Idle Task > > In main - Data22 Index:8 > > In main - Data23 Index:8 > > In main - Data24 Index:8 > > In main - Data25 Index: > In main - Data1099 Index:407 > > In main - Data1100 Index:407 > XMK: Start > XMK: Initializing Hardware... > XMK: Initializing interrupt controller > XMK: Connecting timer interrupt > XMK: Starting the interrupt controller > XMK: Initializing PIT device. > XMK: System initialization... > XMK: Enabling interrupts and starting system... > > prog_main(407) called > > In main - Data1101 Index:408 > Idle Task > > In main - Data1102 Index:408 > XMK: Start > XMK: Initializing Hardware... > XMK: Initializing interrupt controller > XMK: Connecting timer interrupt > XMK: Starting the interrupt controller > XMK: Initializing PIT device. > XMK: System initialization... > XMK: Enabling interrupts and starting system... > > prog_main(408) called > > In main - Data1103 Index:409 > Idle Task > > etc!!!!