Look at the documentation for SetErrorMode() specifically regarding the
SEM_NOALIGNMENTFAULTEXCEPT.
On Alpha, the performance cost for an alignment fixup is huge (and IA64 is reputed
to be as bad). The compiler provided the “__unaligned” keyword for pointers to
instruct the compiler to take the extra steps to load/store from a potentially
unaligned source. The code to do this is 3 times slower, but this is far less of
a hit than if the OS has to perform the fixups automatically.
For the worst performance possible on IA64/Alpha simply specify
SEM_NOALIGNMENTFAULTEXCEPT at process invocation, and make sure you have lots of
unaligned data.
As an example of what will cause an exception:
#pragma pack(1)
typedef struct {
char c;
long d;
} MYSTRUCT;
#pragma pack()
MYSTRUCT mystruct = (MYSTRUCT *) new char[sizeof(MYSTRUCT)];
mystruct->d = 23; // exception
Regards,
Paul Bunn, UltraBac.com, 425-644-6000
Microsoft MVP - WindowsNT/2000
http://www.ultrabac.com
-----Original Message-----
From: Shaun Ruffell [mailto:xxxxx@tenpennies.com]
Sent: Monday, April 30, 2001 10:32 PM
To: NT Developers Interest List
Subject: [ntdev] RE: why use STRUCTURE in C??
If you don’t mind me asking, what are the conditions that can cause the
exceptions?
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of Paul Bunn
Sent: Monday, April 30, 2001 10:34 AM
To: NT Developers Interest List
Subject: [ntdev] RE: why use STRUCTURE in C??
Actually, the amount of memory used by the structure in your example is
determined
by the value of the “packing” set by the compiler options and modified by
the
#pragma pack(x) statement. The default packing is 8 bytes, and indeed some
APIs
used to actually fail (bugs in the headers) if you modified the packing
default.
When considering packing, you should know that this can create unaligned
data in
memory which can cause a performance hit when referencing that memory. On
the x86
architecture I don’t think the hit is that bad (but it depends also on the
motherboard/chipset in use). On the IA64 architecture (and Alpha) the
performance
impact of placing data on unaligned boundaries is HUGE (and can cause
exceptions
in some cases).
Regards,
Paul Bunn, UltraBac.com, 425-644-6000
Microsoft MVP - WindowsNT/2000
http://www.ultrabac.com
-----Original Message-----
From: Girish Desai [mailto:xxxxx@operamail.com]
Sent: Monday, April 30, 2001 9:55 AM
To: NT Developers Interest List
Subject: [ntdev] RE: why use STRUCTURE in C??
Hello All,
I understand the high level concept of strcutre. I heard that using
structure
gives more efficient use of memory.
For example, If I declare char, int and char seperately, It may consume 32
bit
of memory as compiler tells us when we use sizeof. But internally it will
occupy more bytes, which is hidden to us by compiler or by OS. I am not sure
about this.
But if I declare the same thing is structure, like
struct ABC{ int
char
int
}
When we say, sizeof(ABC), it will be equal to size of( int+char+int). But
internally it will occupy less memory. Compiler or OS will do that job. My
question is, how does OS/compiler achieves this? My question is more related
to code optimization.
The enviornment here is x86 and NT. Compilers are again, any MS compilers…
Thanks,
G!r!
===== Original Message From Gary Little =====
>Oh …
>
>Because if you don’t use structures then you add the BASI back to the C and
>end up with BASIC … and THAT is a terrible place to be!!!
>
>Gary
>
>-----Original Message-----
>From: Jamey Kirby [mailto:xxxxx@storagecraft.com]
>Sent: Sunday, April 29, 2001 10:30 AM
>To: NT Developers Interest List
>Subject: [ntdev] RE: why use STRUCTURE in C??
>
>
>I am at a loss for words…
>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com]On Behalf Of Girish Desai
>> Sent: Friday, April 27, 2001 10:56 AM
>> To: NT Developers Interest List
>> Subject: [ntdev] why use STRUCTURE in C??
>>
>>
>> Hello All,
>>
>> This question may not be related to NT. This question is about
>> structures in
>> C.
>>
>> Why should we use structures in C? I would like to know more in
>> the context of
>> memeory utilization…
—
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com