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

Function ClockPro_remove_obj

libCacheSim/cache/eviction/ClockPro.c:259–285  ·  view source on GitHub ↗

* @brief remove the given object from the cache * note that eviction should not call this function, but rather call * `cache_evict_base` because we track extra metadata during eviction * * and this function is different from eviction * because this is used for user trigger * remove, and eviction is used by the cache to make space for new objects * * it needs to call cache_remove_obj_base b

Source from the content-addressed store, hash-verified

257 * @param obj
258 */
259static void ClockPro_remove_obj(cache_t *cache, cache_obj_t *obj) {
260 ClockPro_params_t *params = (ClockPro_params_t *)cache->eviction_params;
261
262 DEBUG_ASSERT(obj != NULL);
263 cache_obj_t *hand_hot_prev = params->hand_hot->queue.prev;
264
265 if (obj->clockpro.status == CLOCKPRO_TEST) {
266 params->mem_test -= obj->obj_size;
267 } else if (obj->clockpro.status == CLOCKPRO_COLD) {
268 params->mem_cold -= obj->obj_size;
269 } else if (obj->clockpro.status == CLOCKPRO_HOT) {
270 params->mem_hot -= obj->obj_size;
271 }
272
273 if (params->hand_test == obj) {
274 params->hand_test = obj->queue.next;
275 }
276 if (params->hand_cold == obj) {
277 params->hand_cold = obj->queue.next;
278 }
279 if (params->hand_hot == obj) {
280 params->hand_hot = obj->queue.next;
281 }
282
283 remove_obj_from_list(&params->hand_hot, &hand_hot_prev, obj);
284 cache_remove_obj_base(cache, obj, true);
285}
286
287/**
288 * @brief remove an object from the cache

Callers 1

ClockPro_removeFunction · 0.85

Calls 2

remove_obj_from_listFunction · 0.85
cache_remove_obj_baseFunction · 0.85

Tested by

no test coverage detected