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


Groups > comp.arch.embedded > #23493

Re: Use RAM to modify a field

From David Brown <david.brown@hesbynett.no>
Newsgroups comp.arch.embedded
Subject Re: Use RAM to modify a field
Date 2016-04-05 08:02 +0200
Organization A noiseless patient Spider
Message-ID <ndvk76$8vn$1@dont-email.me> (permalink)
References <9b2dncOkiOffiWLLnZ2dnUU7-cnNnZ2d@giganews.com> <Gvydnbux9K3U-J3KnZ2dnUU7-N-dnZ2d@giganews.com> <ndt2uf$dkd$1@dont-email.me> <mJudnS3jsJLyPp_KnZ2dnUU7-R-dnZ2d@giganews.com> <dvc5gbhdv7njh421r8uvq7ufp7o6otfjuf@4ax.com>

Show all headers | View raw


On 04/04/16 20:42, upsidedown@downunder.com wrote:
> On Mon, 04 Apr 2016 12:25:03 -0500, Tim Wescott
> <seemywebsite@myfooter.really> wrote:
> 
>> On Mon, 04 Apr 2016 08:55:15 +0200, David Brown wrote:
>>
>>> On 03/04/16 02:35, Tim Wescott wrote:
>>>> On Fri, 01 Apr 2016 19:37:22 -0500, srao wrote:
>>>>
>>>>> I need to use Copy and 8K block of data (from a parameter block
>>>>> address in flash) to RAM, modify data at a particular offset and copy
>>>>> the contents back to flash. The size of the RAM is 256K.  I believe
>>>>> dynamic memory allocation with heap (using a pointer)should work for
>>>>> this? Would like to know if this would be the right way togo?
>>>>> Note: Please notify if any detail seems missing.
>>>>
>>>> A general description of what you're doing would be useful.
>>>>
>>>> If it's an embedded system and it has to run forever, using the heap is
>>>> probably a bad idea (Google "heap fragmentation").  Truly paranoid*
>>>> embedded engineers would allocate the block statically unless that
>>>> makes the system run out of RAM.  If they did NOT allocate it
>>>> statically, then they would ask themselves if they have enough memory
>>>> in the first place.
>>>>
>>>> * In embedded, "paranoid" often means "successful"
>>>>
>>>>
>>> When you have 256K of ram on the chip, and only need 8K for this block
>>> or buffer, then it's not just the paranoid developers that would use
>>> static allocation - it's the lazy* ones too.
>>>
>>> * In embedded, "lazy" also often means "successful".  Good enough is
>>> good enough - a program that does it's job in a simple way is at least
>>> as good as one that does the job in a more advanced way, while the
>>> simpler way has lower development costs and therefore a happier
>>> customer.
>>
>> True, in my experience -- each line of code is an opportunity for a bug, 
>> so fewer lines of code often means fewer bugs.
>>
>> (Unless the pointy-haired boss starts handing out awards for fewest lines 
>> of code to get the job done -- then your job becomes an obfuscated code 
>> contest, and bug counts go up.)
> 
> It depends very much about the expected number of units produced every
> year. If the expected volume is 100 units or less, it makes sense of
> less optimized, preferably COTS devices.
> 
> However, if the expected volume is millions of units each year, t
> makes sense to do a lot of optimization.

You are mixing up the size of the source code (lines of code) and the
size of the object code.  For high volume products, smaller object code
can mean using a part with less flash, leading to real cost savings.
For low volume products, you usually should not worry about the code
size (until you risk exceeding the available flash for that type of device).

But Tim is talking about source code lines.  While there is clearly a
correlation between source code size and object code size, there is a
wide range of possible scaling factors.  Tim recommends avoiding making
the source code unnecessarily large or complicated - but also avoiding
making it unnecessarily compact.  That is, of course, good advice.
Unfortunately there are some PHB's that reward very tight code (usually
in the mistaken belief that this means smaller object code) - and there
are perhaps even more that reward loose and wordy code (in the mistaken
belief that lines of code written is a measure of productivity).



> 
> An anecdote from the TV industry when discrete components were used:
> Quite a lot of engineering effort could be used to optimize some
> circuit so that cheaper resistors with 20 % tolerance could be used,
> instead of the 5 % resistors originally designed.
> 

Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-01 19:37 -0500
  Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-02 19:35 -0500
    Re: Use RAM to modify a field David Brown <david.brown@hesbynett.no> - 2016-04-04 08:55 +0200
      Re: Use RAM to modify a field Jack <jack4747@gmail.com> - 2016-04-04 00:52 -0700
      Re: Use RAM to modify a field Grant Edwards <invalid@invalid.invalid> - 2016-04-04 14:24 +0000
      Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-04 12:25 -0500
        Re: Use RAM to modify a field upsidedown@downunder.com - 2016-04-04 21:42 +0300
          Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-04 15:41 -0500
          Re: Use RAM to modify a field David Brown <david.brown@hesbynett.no> - 2016-04-05 08:02 +0200
    Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-04 11:42 -0500
    Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-04 12:09 -0500
      Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-04 12:34 -0500
        Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-04 13:41 -0500
          Re: Use RAM to modify a field Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-04 18:49 +0000
            Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-04 15:46 -0500
              Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-04 16:32 -0500
                Re: Use RAM to modify a field Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-04-04 21:48 +0000
          Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-04 15:55 -0500
            Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-04 17:49 -0500
              Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-05 12:39 -0500
                Re: Use RAM to modify a field Tim Wescott <seemywebsite@myfooter.really> - 2016-04-05 15:55 -0500
                Re: Use RAM to modify a field lasselangwadtchristensen@gmail.com - 2016-04-05 14:45 -0700
                Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-05 19:22 -0500
          Re: Use RAM to modify a field David Brown <david.brown@hesbynett.no> - 2016-04-05 08:29 +0200
        Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-04 15:50 -0500
          Re: Use RAM to modify a field David Brown <david.brown@hesbynett.no> - 2016-04-05 08:38 +0200
            Re: Use RAM to modify a field Tim Wescott <tim@seemywebsite.com> - 2016-04-05 11:11 -0500
            Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-05 11:46 -0500
        Re: Use RAM to modify a field David Brown <david.brown@hesbynett.no> - 2016-04-05 08:17 +0200
          Re: Use RAM to modify a field Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2016-04-05 09:58 +0300
            Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-05 11:54 -0500
              Re: Use RAM to modify a field Tauno Voipio <tauno.voipio@notused.fi.invalid> - 2016-04-05 22:46 +0300
                Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-05 18:21 -0500
                Re: Use RAM to modify a field Reinhardt Behm <rbehm@hushmail.com> - 2016-04-06 12:58 +0800
                Re: Use RAM to modify a field "srao" <109468@EmbeddedRelated> - 2016-04-06 11:57 -0500
                Re: Use RAM to modify a field Dave Nadler <drn@nadler.com> - 2016-04-06 10:20 -0700
          Re: Use RAM to modify a field Tim Wescott <tim@seemywebsite.com> - 2016-04-05 11:04 -0500

csiph-web