Exemple #1
0
hrt_vaddress sh_css_refcount_alloc(
	int32_t id, const size_t size, const uint16_t attribute)
{
	hrt_vaddress ptr;
	struct sh_css_refcount_entry *entry = NULL;
	uint32_t i;

	assert(size > 0);
	assert(id != FREE_BUF_CACHE);

	for (i = 0; i < myrefcount.size; i++) {
		entry = &myrefcount.items[i];
		if ((entry->id == FREE_BUF_CACHE) && (entry->size == size)) {
			entry->id = id;
			assert(entry->count == 0);
			entry->count = 1;
			assert(entry->data != mmgr_NULL);
			if (attribute & MMGR_ATTRIBUTE_CLEARED)
				mmgr_clear(entry->data, size);
			sh_css_dtrace(SH_DBG_TRACE_PRIVATE,
				"sh_css_refcount_alloc(%x) 0x%x "
				"reused from cache, refcnt %d\n",
				id, entry->data, entry->count);

			return entry->data;
		}
	}

	ptr = mmgr_alloc_attr(size, attribute);
	assert(ptr != mmgr_NULL);

	/* This address should not exist in the administration yet */
	assert(!find_entry(ptr));
	entry = find_free_entry(ptr);

	assert(entry != NULL);
	if (entry == NULL)
		return mmgr_NULL;
	assert(entry->data == mmgr_NULL);
	

	entry->id = id;
	entry->data = ptr;
	entry->size = size;
	entry->count = 1;

	sh_css_dtrace(SH_DBG_TRACE_PRIVATE,
		"sh_css_refcount_alloc(%x) 0x%x "
		"new alloc refcnt %d\n",
		id, ptr, entry->count);


	return ptr;
}
Exemple #2
0
int peos_create_instance(char *model_file,peos_resource_t *resources,int num_resources)
{
    peos_context_t *context;

    if ((context = find_free_entry()) == NULL) {
        return -1;
    }

    if ((context->process_graph = makegraph(model_file)) != NULL) {
	context->pid = peos_get_pid(context);
	context->num_resources = num_resources;
	context -> resources = resources;
        strcpy(context->model, model_file);
        context->status = PEOS_READY;
	initialize_graph(context->process_graph, context->pid);
	return (context->pid); 
    }
    
    return -1;
}