src/libruntime/rmem/cache.c
/**
 * @brief Evicts pages from the cache based on the LRU replacement policy.
 *
 * @param pgnum Number of the target page.
 *
 * @returns Upon successful completion, the index of the page is
 * returned. Upon failure a negative error code is returned instead.
 */
@brief Evicts pages from the cache based on the LRU replacement policy.
@param pgnum Number of the target page.

@returns Upon successful completion, the index of the page is
returned. Upon failure a negative error code is returned instead.
@brief Evicts pages from the cache based on the LRU replacement policy . @param pgnum Number of the target page . @returns Upon successful completion the index of the page is returned . Upon failure a negative error code is returned instead .
static int nanvix_rcache_age_update_lru(rpage_t pgnum)
{
	int idx;
	cache_time++;
	if (cache_policy == RMEM_CACHE_LRU)
	{
		if ((idx = nanvix_rcache_page_search(pgnum)) < 0)
		    return (-EFAULT);
		cache_lines[idx].age += cache_time;
	} else if (cache_policy == RMEM_CACHE_AGING) {
		if ((idx = nanvix_rcache_page_search(pgnum)) < 0)
		    return (-EFAULT);
		nanvix_update_aging(pgnum);
	}
	return (0);
}
static int nanvix_rcache_age_update_lru ( rpage_t pgnum ) { int idx ; cache_time ++ ; if ( cache_policy == RMEM_CACHE_LRU ) { if ( ( idx = nanvix_rcache_page_search ( pgnum ) ) < 0 ) return ( - EFAULT ) ; cache_lines [ idx ] . age += cache_time ; } else if ( cache_policy == RMEM_CACHE_AGING ) { if ( ( idx = nanvix_rcache_page_search ( pgnum ) ) < 0 ) return ( - EFAULT ) ; nanvix_update_aging ( pgnum ) ; } return ( 0 ) ; }
@brief Evicts pages from the cache based on the LRU replacement policy.
@brief Evicts pages from the cache based on the LRU replacement policy .