MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / CAR_insert

Function CAR_insert

libCacheSim/cache/eviction/CAR.c:232–257  ·  view source on GitHub ↗

* @brief insert an object into the cache, * update the hash table and cache metadata * this function assumes the cache has enough space * and eviction is not part of this function * * @param cache * @param req * @return the inserted object */

Source from the content-addressed store, hash-verified

230 * @return the inserted object
231 */
232static cache_obj_t *CAR_insert(cache_t *cache, const request_t *req){
233 CAR_params_t *params = (CAR_params_t *)(cache->eviction_params);
234 cache_obj_t *obj = cache_insert_base(cache, req);
235
236 if(
237 (params->curr_obj_in_L1_ghost || params->curr_obj_in_L2_ghost)
238 ) {
239 // Insert at the tail of T2
240 obj->CAR.lru_id = 2;
241 obj->CAR.reference = false; // Set the page reference bit to 0
242 append_obj_to_tail(&params->L2_data_head, &params->L2_data_tail,obj);
243 params->L2_data_size += req->obj_size + cache->obj_md_size;
244
245 params->curr_obj_in_L1_ghost = false;
246 params->curr_obj_in_L2_ghost = false;
247 } else {
248 // Insert at the tail of T1
249 obj->CAR.lru_id = 1;
250 obj->CAR.reference = false; // Set the page reference bit to 0
251 append_obj_to_tail(&params->L1_data_head, &params->L1_data_tail,obj);
252 params->L1_data_size += req->obj_size + cache->obj_md_size;
253
254 }
255
256 return obj;
257}
258
259/**
260 * @brief find the object to be evicted

Callers

nothing calls this directly

Calls 2

cache_insert_baseFunction · 0.85
append_obj_to_tailFunction · 0.85

Tested by

no test coverage detected