library/src/semaphores/BP-Semaphores.cc
// Simple check to see if there is a lock table for the given semaphore (lock
// table holds a cascading set of locks demonstrating which threads are waiting)
Simple check to see if there is a lock table for the given semaphore (lock
table holds a cascading set of locks demonstrating which threads are waiting)
Simple check to see if there is a lock table for the given semaphore ( lock table holds a cascading set of locks demonstrating which threads are waiting )
BP_ERROR_T BP_SemaphoreLockTableExistsInGHT(P_BP_SEMAPHORE_INFO sem)
{
	BP_SEMAPHORE_VALIDATE_WORKING_ENVIRONMENT(ERR_FAILURE);
	if(!sem)
		return ERR_FAILURE;
	if(!strnlen(sem->uuid_key, 1))
		return ERR_FAILURE;
	BP_GHT_ENTER_CRITICAL_SECTION;
	P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL;
	char *table_path[10];
	BP_ZERO_STACK(table_path);
	table_path[0] = "system";
	table_path[1] = "semaphores";
	table_path[2] = sem->uuid_key;
	table_path[3] = "locks";
	table_path[4] = NULL;
	tmp_lookup = BP_HashRegLookupTableByPath(NULL, table_path);
	if(!tmp_lookup)
		BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_FAILURE);
	BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC(ERR_SUCCESS);
}
BP_ERROR_T BP_SemaphoreLockTableExistsInGHT ( P_BP_SEMAPHORE_INFO sem ) { BP_SEMAPHORE_VALIDATE_WORKING_ENVIRONMENT ( ERR_FAILURE ) ; if ( ! sem ) return ERR_FAILURE ; if ( ! strnlen ( sem -> uuid_key , 1 ) ) return ERR_FAILURE ; BP_GHT_ENTER_CRITICAL_SECTION ; P_BP_HASH_TABLE_KEYED_ENTRY tmp_lookup = NULL ; char * table_path [ 10 ] ; BP_ZERO_STACK ( table_path ) ; table_path [ 0 ] = " " ; table_path [ 1 ] = " " ; table_path [ 2 ] = sem -> uuid_key ; table_path [ 3 ] = " " ; table_path [ 4 ] = NULL ; tmp_lookup = BP_HashRegLookupTableByPath ( NULL , table_path ) ; if ( ! tmp_lookup ) BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_FAILURE ) ; BP_GHT_LEAVE_CRITICAL_SECTION_AND_RETURN_FROM_FUNC ( ERR_SUCCESS ) ; }
Simple check to see if there is a lock table for the given semaphore (lock
table holds a cascading set of locks demonstrating which threads are waiting)
Simple check to see if there is a lock table for the given semaphore ( lock table holds a cascading set of locks demonstrating which threads are waiting )
// validate that there is a working environment // ensure we have a semaphore info structure // ensure the uuid has been set // enter critical section // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Attempt Table Lookup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // declare the lookup pointer // create table path and zero it // now check for the semaphore path // check for tmp_lookup, continue loop if it doesn't exist // return indicating success