Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #482545

Re: Paper on dynamic memory allocation for real-time systems

Subject Re: Paper on dynamic memory allocation for real-time systems
Newsgroups sci.electronics.design
References <%D4GB.50140$6V2.21096@fx21.iad> <osihhn$r04$2@dont-email.me> <85uqucp76e1m9j14ito1m9kqr5fnukkg2o@4ax.com> <oskd0f$lkb$1@dont-email.me>
From bitrex <bitrex@de.lete.earthlink.net>
Message-ID <gmoHB.22084$og2.6621@fx37.iad> (permalink)
Organization frugalusenet - www.frugalusenet.com
Date 2017-10-23 12:00 -0400

Show all headers | View raw


On 10/23/2017 05:33 AM, David Brown wrote:

>> I have often wondered, why C-programmers are so keen of using dynamic
>> memory allocation instead of stack allocation. Is it because some
>> early processors had a very limited stack, typically intended only for
>> return addresses ?
>>
>> In Pascal, you could allocate short lived memory areas on  the stack
>> and pass a pointer to that stack area as a procedure parameter. Of
>> course, this was simplified by having source level nested procedures,
>> so you didn't have to explicitly pass these pointers to low level
>> procedures, since these allocations were readily visible on the outer
>> source code nesting level.
>>
> 
> Many C programmers are quite happy with memory allocated on the stack.
> There are two ways of doing it - VLAs and alloca().  These have the same
> uses as stack allocated memory in Pascal - and the same advantages and
> disadvantages regarding lifetime.

Large stack allocations are discouraged by the CERT-C standard, for 
security reasons:

<https://www.securecoding.cert.org/confluence/display/CINT/MEM05-C.+Avoid+large+stack+allocations>

"Stack overflow has been implicated in Toyota unintended acceleration 
cases, where Camry and other Toyota vehicles accelerated unexpectedly. 
Michael Barr testified at the trial that a stack overflow could corrupt 
the critical variables of the operating system, because they were 
located in memory adjacent to the top of the stack [Samek 2014]."

alloca() can be useful but it isn't ISO C so strictly speaking is 
non-portable. I've also read that unfortunately even the non-portable 
versions included with compilers for some architectures are buggy.

Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-19 12:44 -0400
  Re: Paper on dynamic memory allocation for real-time systems Cursitor Doom <curd@notformail.com> - 2017-10-22 16:38 +0000
    Re: Paper on dynamic memory allocation for real-time systems Bill Martin <wwm@wwmartin.net> - 2017-10-22 10:59 -0700
      Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-22 14:01 -0400
        Re: Paper on dynamic memory allocation for real-time systems Bill Martin <wwm@wwmartin.net> - 2017-10-22 11:09 -0700
    Re: Paper on dynamic memory allocation for real-time systems pcdhobbs@gmail.com - 2017-10-22 11:16 -0700
      Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-22 14:26 -0400
        Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-22 14:30 -0400
    Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-22 14:23 -0400
      Re: Paper on dynamic memory allocation for real-time systems Cursitor Doom <curd@notformail.com> - 2017-10-22 22:49 +0000
        Re: Paper on dynamic memory allocation for real-time systems pcdhobbs@gmail.com - 2017-10-22 16:15 -0700
    Re: Paper on dynamic memory allocation for real-time systems upsidedown@downunder.com - 2017-10-23 08:17 +0300
      Re: Paper on dynamic memory allocation for real-time systems Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-23 09:21 +0100
      Re: Paper on dynamic memory allocation for real-time systems David Brown <david.brown@hesbynett.no> - 2017-10-23 11:33 +0200
        Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-23 12:00 -0400
          Re: Paper on dynamic memory allocation for real-time systems David Brown <david.brown@hesbynett.no> - 2017-10-24 10:19 +0200
            Re: Paper on dynamic memory allocation for real-time systems Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-24 10:08 +0100
              Re: Paper on dynamic memory allocation for real-time systems David Brown <david.brown@hesbynett.no> - 2017-10-24 11:31 +0200
              Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-24 16:48 -0400
                Re: Paper on dynamic memory allocation for real-time systems Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-25 00:49 +0100
                Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-24 20:04 -0400
        Re: Paper on dynamic memory allocation for real-time systems Joseph Gwinn <joegwinn@comcast.net> - 2017-10-24 16:46 -0400
      Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-23 10:53 -0400
        Re: Paper on dynamic memory allocation for real-time systems David Brown <david.brown@hesbynett.no> - 2017-10-24 10:29 +0200
        Re: Paper on dynamic memory allocation for real-time systems upsidedown@downunder.com - 2017-10-24 15:55 +0300
        Re: Paper on dynamic memory allocation for real-time systems upsidedown@downunder.com - 2017-10-24 15:56 +0300
      Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-23 12:35 -0400
      Re: Paper on dynamic memory allocation for real-time systems Sylvia Else <sylvia@not.at.this.address> - 2017-10-24 19:26 +1100
        Re: Paper on dynamic memory allocation for real-time systems Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-24 10:12 +0100
          Re: Paper on dynamic memory allocation for real-time systems Sylvia Else <sylvia@not.at.this.address> - 2017-10-25 11:55 +1100
            Re: Paper on dynamic memory allocation for real-time systems Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-25 08:40 +0100
      Re: Paper on dynamic memory allocation for real-time systems Jasen Betts <jasen@xnet.co.nz> - 2017-10-25 05:58 +0000
        Re: Paper on dynamic memory allocation for real-time systems Tom Gardner <spamjunk@blueyonder.co.uk> - 2017-10-25 08:42 +0100
        Re: Paper on dynamic memory allocation for real-time systems kevin93 <kevin@whitedigs.com> - 2017-10-25 07:29 -0700
          Re: Paper on dynamic memory allocation for real-time systems Jasen Betts <jasen@xnet.co.nz> - 2017-10-28 19:49 +0000
        Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-25 17:28 -0400
        Re: Paper on dynamic memory allocation for real-time systems David Brown <david.brown@hesbynett.no> - 2017-10-27 09:25 +0200
  Re: Paper on dynamic memory allocation for real-time systems Sylvia Else <sylvia@not.at.this.address> - 2017-10-24 19:49 +1100
    Re: Paper on dynamic memory allocation for real-time systems bitrex <bitrex@de.lete.earthlink.net> - 2017-10-24 19:20 -0400

csiph-web