Beispiel #1
0
void
VSM_Init(void)
{
	uint32_t *vsl_log_start;
	pthread_t tp;

	AZ(pthread_mutex_init(&vsl_mtx, NULL));
	AZ(pthread_mutex_init(&vsm_mtx, NULL));

	vsl_log_start = VSM_Alloc(cache_param->vsl_space, VSL_CLASS, "", "");
	AN(vsl_log_start);
	vsl_log_start[1] = VSL_ENDMARKER;
	VWMB();
	do
		*vsl_log_start = random() & 0xffff;
	while (*vsl_log_start == 0);
	VWMB();

	vsl_start = vsl_log_start;
	vsl_end = vsl_start +
	    cache_param->vsl_space / (unsigned)sizeof *vsl_end;
	vsl_ptr = vsl_start + 1;

	VSC_C_main = VSM_Alloc(sizeof *VSC_C_main,
	    VSC_CLASS, VSC_TYPE_MAIN, "");
	AN(VSC_C_main);

	vsl_wrap();
	// VSM_head->starttime = (intmax_t)VTIM_real();
	memset(VSC_C_main, 0, sizeof *VSC_C_main);
	// VSM_head->child_pid = getpid();

	AZ(pthread_create(&tp, NULL, vsm_cleaner, NULL));
}
Beispiel #2
0
static void
vsl_wrap(void)
{

	assert(vsl_ptr >= vsl_start + 1);
	assert(vsl_ptr < vsl_end);
	vsl_start[1] = VSL_ENDMARKER;
	do
		vsl_start[0]++;
	while (vsl_start[0] == 0);
	VWMB();
	if (vsl_ptr != vsl_start + 1) {
		*vsl_ptr = VSL_WRAPMARKER;
		vsl_ptr = vsl_start + 1;
	}
	VSC_C_main->shm_cycles++;
}
Beispiel #3
0
void
VSL_Flush(struct vsl_log *vsl, int overflow)
{
	uint32_t *p;
	unsigned l;

	l = pdiff(vsl->wlb, vsl->wlp);
	if (l == 0)
		return;

	assert(l >= 8);

	p = vsl_get(l - 8, vsl->wlr, overflow);

	memcpy(p + 1, vsl->wlb + 1, l - 4);
	VWMB();
	p[0] = vsl->wlb[0];
	vsl->wlp = vsl->wlb;
	vsl->wlr = 0;
}
void
WSL_Flush(struct worker *wrk, int overflow)
{
	uint32_t *p;
	unsigned l;

	l = pdiff(wrk->wlb, wrk->wlp);
	if (l == 0)
		return;

	assert(l >= 8);

	p = vsl_get(l - 8, wrk->wlr, overflow);

	memcpy(p + 1, wrk->wlb + 1, l - 4);
	VWMB();
	p[0] = wrk->wlb[0];
	wrk->wlp = wrk->wlb;
	wrk->wlr = 0;
}