70 likes | 142 Views
This program demonstrates the implementation of a cache lock system for efficient BLAST execution, including event handling and system safety checks. It identifies system safety levels, errors, and limitations in the cache management process, providing detailed test results.
E N D
Implementation • cpp ../../$MY_TESTCASE.c > $MY_TESTCASE.cpp • gcc -E -I ../../include/ $MY_TESTCASE.cpp > $MY_TESTCASE.i • pblast.opt $MY_TESTCASE.i | tee -a $MY_TESTCASE.pblast.opt • spec.opt $MY_TESTCASE.lock $MY_TESTCASE.i | tee -a $MY_TESTCASE.spec.opt • blastgui.opt &
AV_LOCK(cachelock) pthread_mutex_lock(cachelock) semaphore(cachelock) Cache.cLock Specification and Event int lockStatus = 0;; void __event0__() { if ( lockStatus == 0 ) { lockStatus = 1; } else { __error__(); } } void __event1__() { if ( lockStatus == 1 ) { lockStatus = 0; } else { __error__(); } } global int lockStatus = 0; event { pattern { pthread_mutex_lock(&(cachelock)); } guard { lockStatus == 0 } action { lockStatus = 1; } } event { pattern { pthread_mutex_unlock(&(cachelock)); } guard { lockStatus == 1 } action { lockStatus = 0; } }
‘BLAST’ Execution Log 311 :: 311: FunctionCall(cache_free_one()) :: -1 196 :: 196: Block(cobj@cache_free_one = cachelist.prev;) :: 197 197 :: 197: Pred(Not (cobj@cache_free_one==&(cachelist))) :: 200 200 :: 200: FunctionCall(cacheobj_remove(cobj@cache_free_one)) :: -1 131 :: 131: Block(next@cacheobj_remove = * (cobj@cacheobj_remove ).next;prev@cacheobj_remove = * (cobj@cacheobj_remove ).prev;* (next@cacheobj_remove ).prev = prev@cacheobj_remove;* (prev@cacheobj_remove ).next = next@cacheobj_remove;) ::126 126 :: 126: Block(Return(0);) :: -1 -1 :: Skip :: 201 201 :: 201: Block(disk_usage = disk_usage - * (cobj@cache_free_one ).diskusage;tmpcobj@cache_free_one = * (cobj@cache_free_one );* (cobj@cache_free_one ).obj = 0;) :: 18 18 :: 18: Pred(Not (lockStatus==1)) :: 20 20 :: 20: FunctionCall(__error__()) :: -1 Error found! The system is unsafe :-(
static int cache_clear() { AV_LOCK(cachelock); while(cache_free_one()); AV_UNLOCK(cachelock); return 0; } Problem Identification static int cache_free_one() { struct cacheobj *cobj; struct cacheobj tmpcobj; ... cacheobj_remove(cobj); disk_usage -= cobj->diskusage; tmpcobj = *cobj; cobj->obj = NULL; AV_UNLOCK(cachelock); cacheobj_free(&tmpcobj); AV_LOCK(cachelock); return 1; }
Description Quantity 1 System is safe 9 2 System is not safe 1 3 That’s it! 1 4 Syntax error 3 5 Limitation error 7 6 Parsing error 2 Total: 23 Test Results