示例#1
0
文件: rdc_op.c 项目: bringhurst/tmpi
void rdc_flt_min(void *result, void *source, int count)
{
	float *res=(float *)result;
	float *src=(float *)source;
	union {
		float f;
		int i;
	} tmp1, tmp2;
	register int i;

	if (sizeof(float)==4) {
		for (i=0; i<count; i++) {
			do {
				tmp1.f=res[i];
				tmp2.f=src[i];
	
				if (tmp2.f>=tmp1.f)
					break;
			} while (!cas32((int *)&(res[i]), tmp1.i, tmp2.i));
		}
	}
	else {
		tmpi_error(DBG_INTERNAL, "Architecture assumption failed, float size not equal to 4!");
	}
}
示例#2
0
/*
 * Allocate an unassigned memnode.
 */
int
mem_node_alloc()
{
	int mnode;
	mnodeset_t newmask, oldmask;

	/*
	 * Find an unused memnode.  Update it atomically to prevent
	 * a first time memnode creation race.
	 */
	for (mnode = 0; mnode < max_mem_nodes; mnode++)
		if (cas32((uint32_t *)&mem_node_config[mnode].exists,
		    0, 1) == 0)
			break;

	if (mnode >= max_mem_nodes)
			panic("Out of free memnodes\n");

	mem_node_config[mnode].physbase = (uint64_t)-1;
	mem_node_config[mnode].physmax = 0;
	atomic_add_16(&num_memnodes, 1);
	do {
		oldmask = memnodes_mask;
		newmask = memnodes_mask | (1ull << mnode);
	} while (cas64(&memnodes_mask, oldmask, newmask) != oldmask);

	return (mnode);
}
示例#3
0
/*
 * Increment a CPU's work count and return the old value
 */
static int
xc_increment(struct machcpu *mcpu)
{
	int old;
	do {
		old = mcpu->xc_work_cnt;
	} while (cas32((uint32_t *)&mcpu->xc_work_cnt, old, old + 1) != old);
	return (old);
}
示例#4
0
static uint32_t
rge_atomic_shl32(uint32_t *sp, uint_t count)
{
	uint32_t oldval;
	uint32_t newval;

	/* ATOMICALLY */
	do {
		oldval = *sp;
		newval = oldval << count;
	} while (cas32(sp, oldval, newval) != oldval);

	return (oldval);
}
示例#5
0
文件: rdc_op.c 项目: bringhurst/tmpi
void rdc_int_min(void *result, void *source, int count)
{
	int *res=(int *)result;
	int *src=(int *)source;
	register int i, tmp1, tmp2;

	for (i=0; i<count; i++) {
		do {
			tmp1=res[i];
			tmp2=src[i];

			if (tmp2>=tmp1)
				break;
		} while (!cas32(&(res[i]), tmp1, tmp2));
	}
}
示例#6
0
void
mem_node_add_slice(pfn_t start, pfn_t end)
{
	int mnode;
	mnodeset_t newmask, oldmask;

	/*
	 * DR will pass us the first pfn that is allocatable.
	 * We need to round down to get the real start of
	 * the slice.
	 */
	if (mem_node_physalign) {
		start &= ~(btop(mem_node_physalign) - 1);
		end = roundup(end, btop(mem_node_physalign)) - 1;
	}

	mnode = PFN_2_MEM_NODE(start);
	ASSERT(mnode >= 0 && mnode < max_mem_nodes);

	if (cas32((uint32_t *)&mem_node_config[mnode].exists, 0, 1)) {
		/*
		 * Add slice to existing node.
		 */
		if (start < mem_node_config[mnode].physbase)
			mem_node_config[mnode].physbase = start;
		if (end > mem_node_config[mnode].physmax)
			mem_node_config[mnode].physmax = end;
	} else {
		mem_node_config[mnode].physbase = start;
		mem_node_config[mnode].physmax = end;
		atomic_add_16(&num_memnodes, 1);
		do {
			oldmask = memnodes_mask;
			newmask = memnodes_mask | (1ull << mnode);
		} while (cas64(&memnodes_mask, oldmask, newmask) != oldmask);
	}

	/*
	 * Inform the common lgrp framework about the new memory
	 */
	lgrp_config(LGRP_CONFIG_MEM_ADD, mnode, MEM_NODE_2_LGRPHAND(mnode));
}