473,756 Members | 6,970 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to reduce Zero Initialised region.

Hi ,
I work on an ARM processor based embedded system. Code is mainly in
C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!

two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
2. Is there any alternative to this ?
Thanks in Advance,
Ajai.

Jan 31 '07
37 2336
Chris Dollin wrote:
Thad Smith wrote:
>>Ajai Jose wrote:
>>>On Jan 31, 4:48 pm, "Samuel Stearley" <nya...@gmail.c omwrote:
>1. Am I right in doing this (passing pointer instead of making the data structure static) ?

That will make the executable larger. How much increase can be
tolerated ?

I mean passing an extra parameter to a function might increase code
size(text segment). Some additional code for sending the parameter
during function prolog. that is all the penalty right ?
but it will free some space of the ZI region when it comes to big
arrays.

Why do you want to reduce the size of only zero-initialized RAM?

Because that's what they're running out of. It's an embedded system:
some of them have Funny Specifications. I /suspect/, given that it's
an ARM, that there's some zero-initialised memory that's directly
addressable from a dedicated register and hence is only 4K wide.
(If you don't have a dedicated register you need to load the
address into a spare register before addressing, which means either
loading a pointer you /can/ directly address, which, since we've
eliminated "directly addressed from a dedicated register", means
"directly addressed via the PC", which means you may have multiple
copies of the constant lying around, bad news for embedded; or you
have to assemble the constant in-line, taking at least one and
maybe more instructions, ditto.) But that's just an off-topic guess.
I have not worked with ARMs, but suspect that equating zero-initialized
memory with a specific addressing mode is either wrong or an indication
of a deficient compiler.

I have added comp.arch.embed ded to the list, which probably has someone
that can address your particular system, if you specify the
configuration of processor, memory, and compiler. Followups are also
set to comp.arch.embed ded, since the issues here are off-topic for
comp.lang.c.

--
Thad
Feb 1 '07 #21
I work on an ARM processor based embedded system. Code is mainly in
>C language. The project has a huge source base. We are supposed to
optimise it. Most datastructures are declared as static and which
directly go into the Zero Initialised region. We need to cut the size
of this ZI region by at least 30%.
*ONLY* that region? It's OK and useful to move the arrays from the
Zero Initialized region to the Non-Zero Initialized region?

E.g. change from
char netbuffer[2048];
to
char netbuffer[2048] = {1};
The one way i see of doing this is by removing these static arrays
and passing a pointer to the data structure whenever required. but
since these global arrays are used through out the code. A re-write
seems inevitable!
To meet what you asked for, but what I doubt was intended:

Initialize the arrays to something Non-Zero. Then in an initialization
routine, call memset() on them. This has the dubious advantages of:

- Arrays move from the Zero Initialized region (which just needs to be zeroed
out) to the Non-Zero Initialized region (which needs loading with data from
somewhere).
- The amount of RAM required doesn't get any smaller.
- If code is loaded from disk, it takes longer and the executable is bigger.
- If Non-Zero Initialized data is loaded from ROM, you need more ROM space
for the shadow image of initialized data.
- The code section gets a little bigger for the initialization code.
- The startup time gets a little longer for the initialization code.
>two questions I had.
1. Am I right in doing this(passing pointer instead of making the data
structure static) ?
You still have to allocate the array, whether you have a pointer to it
or not. If the array isn't static, what is it? Automatic? Allocated
with malloc()?
>2. Is there any alternative to this ?
One way you CAN save memory deals with the required lifetime of
these arrays. If they are all needed simultaneously, your overall
RAM requirement won't go down. If they have separate lifetimes,
you could possibly save a lot with auto (but these take up space,
too!) or malloc() allocation, keeping the array in existence only
while it is needed. But this probably involves a major rewrite of
the code.

Feb 1 '07 #22
Christopher Layne <cl****@com.ano dizedwrites:
[...]
Telling people how to act doesn't do a damn thing - demonstrating usually
yields better results.
Great. Please demonstrate for us how we should act.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 1 '07 #23
Keith Thompson wrote:
>Telling people how to act doesn't do a damn thing - demonstrating usually
yields better results.

Great. Please demonstrate for us how we should act.
Which is somehow worse than telling you how to act? Do you believe that?
Feb 1 '07 #24
Christopher Layne <cl****@com.ano dizedwrites:
Keith Thompson wrote:
Telling people how to act doesn't do a damn thing - demonstrating usually
yields better results.
Great. Please demonstrate for us how we should act.

Which is somehow worse than telling you how to act? Do you believe that?
Looking back up the thread:

Ajai Jose wrote "rgt" when he meant "right".

CBFalconer pointed it out, and jokingly suggested several things that
"rgt" might expand to. (I read CBFalconer's followup as good-natured
humor, not as harsh criticism, but humor doesn't always come across
well in a plain-text medium.)

Ajai Jose apologized.

Samuel Stearley pointed out that the actual meaning was clear enough.

That should have been the end of it, but you felt the need to jump in
and insult the "comp.lang. c pedants".

You complain about us "telling people how to act" while telling us how
to act. Do you not see the irony?

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Feb 1 '07 #25
Keith Thompson wrote:
>
You complain about us "telling people how to act" while telling us how
to act. Do you not see the irony?
I can definitely see how you would take it that way. My implication was more
along the lines of "is it really that important to create a sub-thread about
every "rgt, plz" etc. issued here? It's happens like clockwork, everytime.

Feb 1 '07 #26
Christopher Layne wrote:
Samuel Stearley wrote:
>>Really sorry for that....(its probably just me while winding up
from work, hasty update ) in any case its not an insult.
rgt =right.

Its not that hard to understand that you meant 'right' and were
not intending any insult.

It's just more fun for the comp.lang.c pedants to spin their wheels
on. Don't they have anything productive to do?

Serious fear of collapse of everything structured - as if not
replying in a snarky manner to the guy's lack of vowels will result
in everyone doing it tomorrow.

Telling people how to act doesn't do a damn thing - demonstrating
usually yields better results.
Did I really have to put a smiley after:
rgt? red/green/turquoise? rabid grovelling twerp? rapacious
grown teenager? redundant governmental tax? Please spell out
your insults.
I spent some time thinking up translations :-)

--
<http://www.cs.auckland .ac.nz/~pgut001/pubs/vista_cost.txt>

"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
Feb 1 '07 #27
On Feb 1, 10:38 am, Keith Thompson <k...@mib.orgwr ote:
to act. Do you not see the irony?

Thanks to all the respondents,
I am trying out what Eric Suggested. that is calloc when required and
just keep the pointer global.
Regards,
Ajai Jose.

Feb 1 '07 #28
Christopher Layne <cl****@com.ano dizedwrites:
Samuel Stearley wrote:
>>Really sorry for that....(its probably just me while winding up from
work, hasty update ) in any case its not an insult.
rgt =right.

Its not that hard to understand that you meant 'right' and were not
intending any insult.

It's just more fun for the comp.lang.c pedants to spin their wheels on. Don't
they have anything productive to do?

Serious fear of collapse of everything structured - as if not replying in a
snarky manner to the guy's lack of vowels will result in everyone doing it
tomorrow.

Telling people how to act doesn't do a damn thing - demonstrating usually
yields better results.
I have pointed this out numerous times. Teach by example.

But CBF in particular likes to hear the sound of his own voice. I
wouldn't mind but most code excerpts he has posted look and taste like
some beginners home brew anyway.

Feb 2 '07 #29
Christopher Layne <cl****@com.ano dizedwrites:
Keith Thompson wrote:
>>
You complain about us "telling people how to act" while telling us how
to act. Do you not see the irony?

I can definitely see how you would take it that way. My implication was more
along the lines of "is it really that important to create a sub-thread about
every "rgt, plz" etc. issued here? It's happens like clockwork, everytime.
Yup. Little man's disease is a common affliction. Can't wait to correct
people at every opportunity. A shame as there are some seriously good
guys there whose output is clouded by the usual people and their
attempts to out do each other.
Feb 2 '07 #30

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
6330
by: Margaret MacDonald | last post by:
Probably it's something dumb that I'm doing/not doing, but echo doesn't seem to want to echo a literal zero when the value of some var is zero. E.g.: $foo = 0 ; echo 'foo is ' . $foo ; yields: foo is
181
8880
by: Tom Anderson | last post by:
Comrades, During our current discussion of the fate of functional constructs in python, someone brought up Guido's bull on the matter: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 He says he's going to dispose of map, filter, reduce and lambda. He's going to give us product, any and all, though, which is nice of him.
1
1479
by: John Smith | last post by:
I have a two dimentional char array. Before filling it using strtok(), I reset its elements to '\0' using two nested for loops. The code works as I hope it would but I wonder whether I really need to reset the array. The program would run faster if I don't need to reset. ------------------------------------------ int Array(void) .................
3
2399
by: Ali Sahin | last post by:
Hi there, I'd like to transform a XML-File to PDF. The XML-File ist build like followed: <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <?xml-stylesheet type="text/xsl" href="D:\app\jboss-3.2.5\server\default\deploy\xifs.war\WEB-INF\classes\de\xifs\resource\xml\de\xifs\resource\xml\dunningaccountreport_de.xsl"?> <!DOCTYPE entities >
14
52474
by: rocketman768 | last post by:
Man, that title should be in a poem, but anyways...So, I have this program, and it has an array of 40 million elements. The problem is that I have a for loop that continually is doing stuff to this array, and for each iteration, I have to zero out the array. This is how I am currently doing it: // Zero out the lnscores for( count=0; count < chunksize; count++ ) lnscores = 0; Is there no quicker way to do this? I know there must be...
3
2939
by: mark | last post by:
I have a table of UK companies whose records I want to filter using a map of postcode regions. For the benfit of people outside the UK, our postcodes are a pain to work with because they are not a standard length, and the part which identifies the region isn't a standard length either. The first letters of the postcode denotes a general region, and then sub-regions are denoted by the following numbers and letters.
1
3296
by: replyrpatil | last post by:
What I am trying to do: I need to print a compact access report (font 6 size) created using RTF2 program developed by Stephen Lebans to generate a TIF image of custom size (5.5 in x 2.0 in) Problem Recreation : Download attached RAR file (http://download.yousendit.com/627919383AFAA7E3 ) Steps 1) Install RTF2 program created by Lebans 2) Install ZAN Image Printer (Virtual Printer) 3) Create Custom Paper Size ----...
10
2436
by: werasm | last post by:
Hi all, I recently just stumbled upon this code. According to what I see in the standard it should be fine, but I've always done the initialization explicitly myself: //.h //... struct X {
2
1991
by: JenavaS | last post by:
Hi all, I have a query: SELECT Data.Region, Data.Dept, Data.Year, Data.Month, Data.Week, Data.Elapsed, Data. AS WpComp, Data. AS CpComp, IIf(=53 And ="JAN,WK4",/2,) AS AdjLyComp, round((-IIf(=53 And ="JAN,WK4",/2,))/IIf(=53 And ="JAN,WK4",/2,),6) AS WpVarLy, round((-IIf(=53 And ="JAN,WK4",/2,))/IIf(=53 And ="JAN,WK4",/2,),6) AS CpVarLy FROM ((Data INNER JOIN Years ON Data.Year=Years.Year) INNER JOIN LyWk ON (Data.Week=LyWk.TyWk) AND...
0
9297
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9904
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9735
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7285
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3395
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2697
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.