This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Printf and _sbrk


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
________________________________________________________________________


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]