mlock in cache

Andrew Haley
Fri Aug 2 14:27:00 GMT 2013

On 08/02/2013 03:12 PM, Christos wrote:
> Hi everyone,
> I am developing a program in C and I want to lock some memory pages in 
> cache, particularly in the core specific level (i.e. level 1). As far as 
> I know the C libraries do not provide an interface to do that so I guess 
> that there must be some particular directives in gcc to do so.

__builtin_prefetch() is what you need.  However, there's no way you'll be
able to lock anything in L1: it'll be evicted very shortly afterwards.


More information about the Gcc-help mailing list