linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* GCC and Memory Organization
@ 2002-04-09 15:07 William N. Zanatta
  2002-04-09 22:12 ` Glynn Clements
  0 siblings, 1 reply; 5+ messages in thread
From: William N. Zanatta @ 2002-04-09 15:07 UTC (permalink / raw)
  To: 'linux-c-programming@vger.kernel.org'

Hello brothers,

   I have a question on memory organization...
   In my Computer Architeture classes, I've learned something like that 
there are two ways to organize data in memory.
   The first one puts it in a linear mode like:

      +---------------+
12k  | z | z |   |   |
      |---------------|
8k   | y | y | z | z |
      |---------------|
4k   | x | x | x | y |
      +---------------+

   And the second way is a non-linear, a block mode like:

      +---------------+
12k  | z | z | z | z |
      |---------------|
8k   | y | y | y |   |
      |---------------|
4k   | x | x |   |   |
      +---------------+

   The second way should be faster than the first one for memory 
management, right?! That a kindda obviuos as it wouldn't be necessary to 
scan all the block to find the next entry. Also it can be expensive 
since the 4k block is allocated for only 2k of real data.

   My question is, how does GCC works with this? Does it have any switch 
for optimizing (or not) the code?? What's the default action???

   Thank you, keep it hard!

William Zanatta


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC and Memory Organization
  2002-04-09 15:07 GCC and Memory Organization William N. Zanatta
@ 2002-04-09 22:12 ` Glynn Clements
  2002-04-11 12:48   ` William N. Zanatta
  2002-04-11 13:22   ` William N. Zanatta
  0 siblings, 2 replies; 5+ messages in thread
From: Glynn Clements @ 2002-04-09 22:12 UTC (permalink / raw)
  To: William N. Zanatta; +Cc: 'linux-c-programming@vger.kernel.org'


William N. Zanatta wrote:

>    I have a question on memory organization...
>    In my Computer Architeture classes, I've learned something like that 
> there are two ways to organize data in memory.
>    The first one puts it in a linear mode like:
> 
>       +---------------+
> 12k  | z | z |   |   |
>       |---------------|
> 8k   | y | y | z | z |
>       |---------------|
> 4k   | x | x | x | y |
>       +---------------+
> 
>    And the second way is a non-linear, a block mode like:
> 
>       +---------------+
> 12k  | z | z | z | z |
>       |---------------|
> 8k   | y | y | y |   |
>       |---------------|
> 4k   | x | x |   |   |
>       +---------------+
> 
>    The second way should be faster than the first one for memory 
> management, right?! That a kindda obviuos as it wouldn't be necessary to 
> scan all the block to find the next entry. Also it can be expensive 
> since the 4k block is allocated for only 2k of real data.
> 
>    My question is, how does GCC works with this? Does it have any switch 
> for optimizing (or not) the code?? What's the default action???

This isn't a compiler issue. The different layouts would require
different source code. The former corresponds to a one-dimensional
array, while the latter corresponds to a two-dimensional array.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC and Memory Organization
  2002-04-09 22:12 ` Glynn Clements
@ 2002-04-11 12:48   ` William N. Zanatta
  2002-04-11 13:22   ` William N. Zanatta
  1 sibling, 0 replies; 5+ messages in thread
From: William N. Zanatta @ 2002-04-11 12:48 UTC (permalink / raw)
  To: Glynn Clements; +Cc: 'linux-c-programming@vger.kernel.org'

Glynn Clements wrote:

> This isn't a compiler issue. The different layouts would require
> different source code. The former corresponds to a one-dimensional
> array, while the latter corresponds to a two-dimensional array.
> 

Do you know any document on the web where I can study more about this issue?


William


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC and Memory Organization
  2002-04-09 22:12 ` Glynn Clements
  2002-04-11 12:48   ` William N. Zanatta
@ 2002-04-11 13:22   ` William N. Zanatta
  2002-04-11 14:07     ` Glynn Clements
  1 sibling, 1 reply; 5+ messages in thread
From: William N. Zanatta @ 2002-04-11 13:22 UTC (permalink / raw)
  To: Glynn Clements; +Cc: 'linux-c-programming@vger.kernel.org'

> 
> This isn't a compiler issue. The different layouts would require
> different source code. The former corresponds to a one-dimensional
> array, while the latter corresponds to a two-dimensional array.
> 

I guess I found something. Looks like I'm talking about the concepts of 
segmentation and paging. Is that right?
In the following site there's a interesting map for understanding the 
concepts of VM.

http://cne.gmu.edu/modules/vm/index.html

Thank you again,

William


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GCC and Memory Organization
  2002-04-11 13:22   ` William N. Zanatta
@ 2002-04-11 14:07     ` Glynn Clements
  0 siblings, 0 replies; 5+ messages in thread
From: Glynn Clements @ 2002-04-11 14:07 UTC (permalink / raw)
  To: William N. Zanatta; +Cc: 'linux-c-programming@vger.kernel.org'


William N. Zanatta wrote:

> > This isn't a compiler issue. The different layouts would require
> > different source code. The former corresponds to a one-dimensional
> > array, while the latter corresponds to a two-dimensional array.
> > 
> 
> I guess I found something. Looks like I'm talking about the concepts of 
> segmentation and paging. Is that right?

Maybe, but segmentation and paging are only really relevant if you're
designing a CPU or an OS kernel. A program just sees a flat address
space.

-- 
Glynn Clements <glynn.clements@virgin.net>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2002-04-11 14:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-09 15:07 GCC and Memory Organization William N. Zanatta
2002-04-09 22:12 ` Glynn Clements
2002-04-11 12:48   ` William N. Zanatta
2002-04-11 13:22   ` William N. Zanatta
2002-04-11 14:07     ` Glynn Clements

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).