Ejemplo n.º 1
0
int main(int argc, char** argv)
{
	uint64_t old_time;
	NQMMP* mmp = nqmmpnew(73);
	char* a[10000];
	old_time = nq_time_now();
	for (int i = 0; i < 10000; i++)
		a[i] = (char*)nqalloc(mmp);
	for (int j = 1; j < 10000; j++)
		for (int i = 0; i < 1000; i++)
		{
			nqfree(a[i * 10]);
			a[i * 10] = (char*)nqalloc(mmp);
		}
	printf("nqmm elapsed time: %d\n", (int)(nq_time_now() - old_time));
	nqmmpdel(mmp);
	char* b[10000];
	old_time = nq_time_now();
	for (int i = 0; i < 10000; i++)
		b[i] = (char*)nqalloc(73);
	for (int j = 0; j < 10000; j++)
		for (int i = 0; i < 1000; i++)
		{
			nqfree(b[i * 10]);
			b[i * 10] = (char*)nqalloc(73);
		}
	printf("malloc elapsed time: %d\n", (int)(nq_time_now() - old_time));
	return 0;
}
Ejemplo n.º 2
0
int dgmopen(struct devsw *devptr, int forport, int locport)
{
	STATWORD ps;    
	struct	dgblk	*dgptr;
	struct	netq	*nqptr;
	int	slot;
	int	nq=0;
	int	i;

	disable(ps);
	if ( (slot=dgalloc()) == SYSERR) {
		restore(ps);
		kprintf("dgalloc: SYSERR\n");
		return(SYSERR);
	}
	dgptr = &dgtab[slot];
	if (locport == ANYLPORT)
		locport = udpnxtp();
	else {
		for (i=0 ; i<NETQS ; i++)
			if (Net.netqs[i].valid && 
				Net.netqs[i].uport == locport) {
				dgptr->dg_state = DG_FREE;
				restore(ps);
				kprintf("dgmopen: invalid netq %d\n",i);
				return(SYSERR);
			}
	}
	if (dgparse(dgptr,(char *)forport)==SYSERR || (nq=nqalloc())==SYSERR ) {
		dgptr->dg_state = DG_FREE;
		kprintf("dgmopen: bad dgparse or nq=%d\n",nq);
		restore(ps);
		return(SYSERR);
	}
	nqptr = &Net.netqs[nq];
	nqptr->uport = dgptr->dg_lport = locport;
	dgptr->dg_xport = nqptr->xport;
	dgptr->dg_netq = nq;
	dgptr->dg_mode = DG_NMODE;
	restore(ps);
	return(dgptr->dg_dnum);
}