What is pragma align in C?

c, memory-management, operating-system

Solution

This means that `var` structure will be page-aligned (standard page size in most computer architectures is 4K=4096 bytes), i.e. it will be stored at location with address dividable by 4096. Such approach improves performance, since the OS acquires the data in chunks equal to page size from disk (i.e. `paged memory`), by doing what's called `page fault`. Each `page fault` is an additional work for processor and I/O system. Minimizing number of `page faults` is a strong mean to improve performance. If the data isn't page-aligned, access to it might require an additional `page fault`, while only a part of the brought data is needed.

Edit: Although in most cases aligning to 4K is due to memory management, there might be other reasons for alignment, mostly HW restrictions - as was correctly pointed out by @CodePainters.

Problem

Recently when i was going through a code, I found #pragma DATA_ALIGN(var, 4*1024). var is a structure variable that is around 20k long. I searched for this in the internet and could not find anything useful. Can anyone provide me links or shed some light on this?

Original source