[LCP]stdio.h reference

Santosh.Kawade at eyield.com Santosh.Kawade at eyield.com
Tue Jan 8 17:33:41 UTC 2002


The reason for aligning data w.r.t at boundaries is related to architecture of
the microprocessor. The microprocessor fetches data in terms of WORD size  (same
 as the width of the data bus ).
For e.g a 32 bit machine can fetch 32 bits of data from memory in one machine
cycle. If the data is not aligned at WORD boundaries it will have to generate
two fetches to access the data. Hence it doubles the fetch time. 

For e.g an int i is stored in memory at location 0X0032. Suppose it takes 4
bytes (32 bit ) of storage. The microprocessor will fetch data in terms at WORD
boundaries ( multiples of 32 ). If it is aligned it will fetch it in one go, but
suppose if it soted at 0X0020 there will be 2 machine cycles to fetch this data
one at 0X0000 and 0X0032.




____________________Reply Separator____________________
Subject:    Re: [LCP]stdio.h reference
Author: linuxcprogramming at lists.linux.org.au
Date:       1/7/02 9:06 PM

This is more of a conceptual question.
We know that multibyte data must be aligned on a
natural boundary.That is four byte dta on a four byte
boundary and two byte data on two byte boundary and so
forth.But what is the reason behind this.CAn anyone
please explain.What will be the problem if the data is
not aligned???



__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/
_______________________________________________
This is the Linux C Programming List
:  http://lists.linux.org.au/listinfo/linuxcprogramming List
Received: from ftoomsh ([138.25.6.1]) by mailserver.mail1.com with SMTP
  (IMA Internet Exchange 3.11) id 000605D2; Mon, 7 Jan 2002 21:35:47 -0800
Received: from localhost ([127.0.0.1]:2969 "ehlo ftoomsh.progsoc.uts.edu.au")
    by ftoomsh.progsoc.uts.edu.au with ESMTP id <S154936AbSAHFfW>;
    Tue, 8 Jan 2002 16:35:22 +1100
Received: from web9608.mail.yahoo.com ([216.136.129.187]:1664 "HELO
    web9608.mail.yahoo.com") by ftoomsh.progsoc.uts.edu.au with SMTP
    id <S154934AbSAHFGt>; Tue, 8 Jan 2002 16:06:49 +1100
Message-ID: <20020108050646.8238.qmail at web9608.mail.yahoo.com>
Received: from [202.41.97.7] by web9608.mail.yahoo.com via HTTP; Mon, 07 Jan
2002 21:06:46 PST
From:   Priya <prix_s at yahoo.com>
Subject: Re: [LCP]stdio.h reference
To: linuxcprogramming at lists.linux.org.au
In-Reply-To: <LIOJPHGAEIMNFAAA at mailcity.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Return-Path: <prix_s at yahoo.com>
X-Orcpt: rfc822;linuxcprogramming at lists.linux.org.au
Sender: linuxcprogramming-admin at lists.linux.org.au
Errors-To: linuxcprogramming-admin at lists.linux.org.au
X-BeenThere: linuxcprogramming at lists.linux.org.au
X-Mailman-Version: 2.0.3
Precedence: bulk
Reply-To: linuxcprogramming at lists.linux.org.au
List-Help: <mailto:linuxcprogramming-request at lists.linux.org.au?subject=help>
List-Post: <mailto:linuxcprogramming at lists.linux.org.au>
List-Subscribe: <http://lists.linux.org.au/listinfo/linuxcprogramming>,
    <mailto:linuxcprogramming-request at lists.linux.org.au?subject=subscribe>
List-Id: Linux C Programming <linuxcprogramming.lists.linux.org.au>
List-Unsubscribe: <http://lists.linux.org.au/listinfo/linuxcprogramming>,
    <mailto:linuxcprogramming-request at lists.linux.org.au?subject=unsubscribe>
List-Archive: <http://lists.linux.org.au/archives/linuxcprogramming/>
X-Original-Date: Mon, 7 Jan 2002 21:06:46 -0800 (PST)
Date:   Mon, 7 Jan 2002 21:06:46 -0800 (PST)



More information about the linuxCprogramming mailing list