Beispiel #1
0
static void
uninit()
{
	unregister_generic_syscall(LAUNCH_SPEEDUP_SYSCALLS, 1);

	recursive_lock_lock(&sLock);

	// free all sessions from the hashes

	uint32 cookie = 0;
	Session *session;
	while ((session = (Session *)hash_remove_first(sTeamHash, &cookie)) != NULL) {
		delete session;
	}
	cookie = 0;
	while ((session = (Session *)hash_remove_first(sPrefetchHash, &cookie)) != NULL) {
		delete session;
	}

	// free all sessions from the main prefetch list

	for (session = sMainPrefetchSessions; session != NULL; ) {
		sMainPrefetchSessions = session->Next();
		delete session;
		session = sMainPrefetchSessions;
	}

	hash_uninit(sTeamHash);
	hash_uninit(sPrefetchHash);
	recursive_lock_destroy(&sLock);
}
/*!	Calls low resource handlers for the given resources.
	sLowResourceLock must be held.
*/
static void
call_handlers(uint32 lowResources)
{
	if (sLowResourceHandlers.IsEmpty())
		return;

	// Add a marker, so we can drop the lock while calling the handlers and
	// still iterate safely.
	low_resource_handler marker;
	sLowResourceHandlers.Insert(&marker, false);

	while (low_resource_handler* handler
			= sLowResourceHandlers.GetNext(&marker)) {
		// swap with handler
		sLowResourceHandlers.Swap(&marker, handler);
		marker.priority = handler->priority;

		int32 resources = handler->resources & lowResources;
		if (resources != 0) {
			recursive_lock_unlock(&sLowResourceLock);
			handler->function(handler->data, resources,
				low_resource_state_no_update(resources));
			recursive_lock_lock(&sLowResourceLock);
		}
	}

	// remove marker
	sLowResourceHandlers.Remove(&marker);
}
static int lock_tmap(vm_translation_map *map)
{
	TMAP_TRACE("lock_tmap: map %p\n", map);

	if(recursive_lock_lock(&map->lock) == true) {
		// we were the first one to grab the lock
	}

	return 0;
}
/*!	Acquires the map's recursive lock, and resets the invalidate pages counter
	in case it's the first locking recursion.
*/
bool
M68KVMTranslationMap::Lock()
{
	TRACE("%p->M68KVMTranslationMap::Lock()\n", this);

	recursive_lock_lock(&fLock);
	if (recursive_lock_get_recursion(&fLock) == 1) {
		// we were the first one to grab the lock
		TRACE("clearing invalidated page count\n");
		fInvalidPagesCount = 0;
	}

	return true;
}
int32
low_resource_state(uint32 resources)
{
	recursive_lock_lock(&sLowResourceLock);

	if (system_time() - sLastMeasurement > 500000)
		compute_state();

	int32 state = low_resource_state_no_update(resources);

	recursive_lock_unlock(&sLowResourceLock);

	return state;
}
Beispiel #6
0
status_t
Attribute::_Find(const char* name, int32 index)
{
	Put();

	fName = name;

	// try to find it in the small data region
	if (fInode->HasExtraAttributes() 
		&& recursive_lock_lock(&fInode->SmallDataLock()) == B_OK) {
		off_t blockNum;
		fVolume->GetInodeBlock(fInode->ID(), blockNum);
		
		if (blockNum != 0) {
			fBlock.SetTo(blockNum);
			const uint8* start = fBlock.Block() 
				+ fVolume->InodeBlockIndex(fInode->ID()) * fVolume->InodeSize();
			const uint8* end = start + fVolume->InodeSize();
			int32 count = 0;
			if (_FindAttributeBody(start + EXT2_INODE_NORMAL_SIZE 
				+ fInode->Node().ExtraInodeSize(), end, name, index, &count, 
				&fBodyEntry) == B_OK)
				return B_OK;
			index -= count;
		}

		recursive_lock_unlock(&fInode->SmallDataLock());
		fBlock.Unset();
	}

	// then, search in the attribute directory
	if (fInode->Node().ExtendedAttributesBlock() != 0) {
		fBlock.SetTo(fInode->Node().ExtendedAttributesBlock());
		if (_FindAttributeBlock(fBlock.Block(), 
			fBlock.Block() + fVolume->BlockSize(), name, index, NULL, 
			&fBlockEntry) == B_OK)
			return B_OK;
		fBlock.Unset();
	}

	return B_ENTRY_NOT_FOUND;
}
Beispiel #7
0
static inline void
rld_lock()
{
	recursive_lock_lock(&sLock);
}
static void recursive_lock_forward(GenericSharedDeclarations_SharedOf_int32_0_t* value1) 
{
  recursive_lock_lock(value1);
}