Printf and _sbrk
Pierre Habraken
Pierre.Habraken@imag.fr
Tue Apr 30 09:49:00 GMT 2002
Hello,
I am trying to use newlib together with gcc, gas and gdb for teaching
Arm assembly language to undergraduate students.
One software that students have to work on is a small program which
simulates the part in a kernel or OS which manages context switches.
No interrupts are available to the program, they are simulated using the
SWI instruction.
Program execution is emulated using the Gdb "sim" target.
Gcc, Binutils, Newlib and Gdb were compiled for the target arm-elf.
The main procedure of the program installs the SWI vector then
initializes 3 tasks and last starts the 1st task by mean of a call to
SWI.
Afterwards, execution of each task is scheduled according to a round
robin policy : actually, as there are no timer interrupts, each task has
to relinquishes the processor at some point of its code using another
call to SWI.
The main program is started by the simulator in SVC mode.
Tasks run is USER mode.
Now, here is the problem :
- if the main program (running in SVC mode) does NOT execute any printf,
then the first printf called by a task (running in USER mode) makes
the whole program abort and display the message :
_sbrk: Heap and stack collision
- if the main program DOES execute one (at least) call to printf before
launching the 1st task, then everything runs ok until normal
completion of all three tasks.
Did anyone already meet the same sort of behavior ?
What might cause it ?
Thanks in advance for any help !
Pierre
--
________________________________________________________________________
Pierre HABRAKEN - mailto:Pierre.Habraken@imag.fr
Tél: 04 76 82 72 83 - Fax: 04 76 82 72 87
IMAG-LSR BP72 38402 SAINT MARTIN D'HERES Cedex
________________________________________________________________________
More information about the Newlib
mailing list