当前位置: 首页>>代码示例>>C++>>正文


C++ psp函数代码示例

本文整理汇总了C++中psp函数的典型用法代码示例。如果您正苦于以下问题:C++ psp函数的具体用法?C++ psp怎么用?C++ psp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了psp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sptrace_clear

void	sptrace_clear(PsmPartition trace)
{
	PsmAddress	traceHeaderAddress;
	TraceHeader	*trh;
	PsmAddress	elt;
	PsmAddress	nextElt;
	PsmAddress	itemAddress;
	TraceItem	*item;

	if (!trace) return;
	traceHeaderAddress = psm_get_root(trace);
	trh = (TraceHeader *) psp(trace, traceHeaderAddress);
	CHKVOID(trh);
	for (elt = sm_list_first(trace, trh->log); elt; elt = nextElt)
	{
		nextElt = sm_list_next(trace, elt);
		itemAddress = sm_list_data(trace, elt);
		item = (TraceItem *) psp(trace, itemAddress);
		CHKVOID(item);
		if (item->opType == OP_ALLOCATE || item->opType == OP_FREE)
		{
			if (item->refOpNbr == 0)
			{
				continue;	/*	Not matched.	*/
			}

			/*	Delete matched activity from log.	*/

			psm_free(trace, itemAddress);
			CHKVOID(sm_list_delete(trace, elt, NULL, NULL) == 0);
		}
	}
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:33,代码来源:sptrace.c

示例2: sm_rbt_last

PsmAddress	sm_rbt_last(PsmPartition partition, PsmAddress rbt)
{
	SmRbt		*rbtPtr;
	PsmAddress	node;
	PsmAddress	last = 0;
	SmRbtNode	*nodePtr;

	CHKZERO(partition);
	CHKZERO(rbt);
	rbtPtr = (SmRbt *) psp(partition, rbt);
	CHKZERO(rbtPtr);
	if (lockSmrbt(rbtPtr) == ERROR)
	{
		return 0;
	}

	node = rbtPtr->root;
	while (node)
	{
		last = node;
		nodePtr = (SmRbtNode *) psp(partition, node);
		if (nodePtr == NULL)
		{
			putErrmsg("Corrupt red-black tree.", NULL);
			last = 0;
			break;
		}

		node = nodePtr->child[RIGHT];
	}

	unlockSmrbt(rbtPtr);
	return last;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:34,代码来源:smrbt.c

示例3: Sm_list_insert_after

PsmAddress	Sm_list_insert_after(const char *fileName, int lineNbr,
			PsmPartition partition, PsmAddress oldElt,
			PsmAddress data)
{
	SmListElt	*oldEltBuffer;
	PsmAddress	list;
	SmList		*listBuffer;

	CHKZERO(partition);
	CHKZERO(oldElt);
	oldEltBuffer = (SmListElt *) psp(partition, oldElt);
	CHKZERO(oldEltBuffer);
	if ((list = oldEltBuffer->list) == 0)
	{
		putErrmsg(_noListMsg(), NULL);
		return 0;
	}

	listBuffer = (SmList *) psp(partition, list);
	if (lockSmlist(listBuffer) == ERROR)
	{
		putErrmsg(_cannotLockMsg(), NULL);
		return 0;
	}

	return finishInsertingAfter(fileName, lineNbr, partition, oldElt,
			oldEltBuffer, list, listBuffer, data);
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:28,代码来源:smlist.c

示例4: Sm_rbt_traverse

PsmAddress	Sm_rbt_traverse(PsmPartition partition, PsmAddress fromNode,
			int direction)
{
	SmRbtNode	*nodePtr;
	SmRbt		*rbtPtr;
	int		nextNode;

	CHKZERO(partition);
	CHKZERO(fromNode);
	nodePtr = (SmRbtNode *) psp(partition, fromNode);
	CHKZERO(nodePtr);
	rbtPtr = (SmRbt *) psp(partition, nodePtr->rbt);
	CHKZERO(rbtPtr);
	if (lockSmrbt(rbtPtr) == ERROR)
	{
		return 0;
	}

	if (direction != LEFT)
	{
		direction = RIGHT;
	}

	nextNode = traverseRbt(partition, fromNode, direction);
	unlockSmrbt(rbtPtr);
	return nextNode;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:27,代码来源:smrbt.c

示例5: rotateOnce

static PsmAddress	rotateOnce(PsmPartition partition, PsmAddress root,
				int direction)
{
	int		otherDirection = 1 - direction;
	SmRbtNode	*rootPtr;
	PsmAddress	pivot;
	SmRbtNode	*pivotPtr;
	PsmAddress	orphan;
	SmRbtNode	*orphanPtr;

	rootPtr = (SmRbtNode *) psp(partition, root);
	pivot = rootPtr->child[otherDirection];
	pivotPtr = (SmRbtNode *) psp(partition, pivot);
	orphan = pivotPtr->child[direction];
	orphanPtr = (SmRbtNode *) psp(partition, orphan);
	pivotPtr->parent = rootPtr->parent;
	pivotPtr->child[direction] = root;
	pivotPtr->isRed = 0;
	rootPtr->parent = pivot;
	rootPtr->child[otherDirection] = orphan;
	rootPtr->isRed = 1;
	if (orphan)
	{
		orphanPtr->parent = root;
	}

	return pivot;
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:28,代码来源:smrbt.c

示例6: applyRateControl

static void	applyRateControl(Sdr sdr)
{
	BpVdb		*vdb = getBpVdb();
	PsmPartition	ionwm = getIonwm();
	Throttle	*throttle;
	PsmAddress	elt;
	VInduct		*induct;
	VOutduct	*outduct;
	long		capacityLimit;

	sdr_begin_xn(sdr);	/*	Just to lock memory.		*/

	/*	Recalculate limit on local bundle generation.		*/

	manageProductionThrottle(vdb);

	/*	Enable some bundle acquisition.				*/

	for (elt = sm_list_first(ionwm, vdb->inducts); elt;
			elt = sm_list_next(ionwm, elt))
	{
		induct = (VInduct *) psp(ionwm, sm_list_data(ionwm, elt));
		throttle = &(induct->acqThrottle);
		capacityLimit = throttle->nominalRate << 1;
		throttle->capacity += throttle->nominalRate;
		if (throttle->capacity > capacityLimit)
		{
			throttle->capacity = capacityLimit;
		}

		if (throttle->capacity > 0)
		{
			sm_SemGive(throttle->semaphore);
		}
	}

	/*	Enable some bundle transmission.			*/

	for (elt = sm_list_first(ionwm, vdb->outducts); elt;
			elt = sm_list_next(ionwm, elt))
	{
		outduct = (VOutduct *) psp(ionwm, sm_list_data(ionwm, elt));
		throttle = &(outduct->xmitThrottle);
		capacityLimit = throttle->nominalRate << 1;
		throttle->capacity += throttle->nominalRate;
		if (throttle->capacity > capacityLimit)
		{
			throttle->capacity = capacityLimit;
		}

		if (throttle->capacity > 0)
		{
			sm_SemGive(throttle->semaphore);
		}
	}

	sdr_exit_xn(sdr);	/*	Unlock memory.			*/
}
开发者ID:b,项目名称:ION,代码行数:58,代码来源:bpclock.c

示例7: postProbeEvent

PsmAddress	postProbeEvent(IonNode *node, Embargo *embargo)
{
	PsmPartition	ionwm = getIonwm();
	PsmAddress	addr;
	IonProbe	*probe;
	IonVdb		*ionvdb;
	IonNeighbor	*neighbor;
	PsmAddress	nextElt;
	unsigned int	rtlt;		/*	Round-trip light time.	*/
	int		interval = 6;	/*	Minimum 6-sec interval.	*/
	PsmAddress	elt;
	IonProbe	*pr;

	CHKZERO(node);
	CHKZERO(embargo);
	addr = psm_zalloc(ionwm, sizeof(IonProbe));
	if (addr == 0)
	{
		putErrmsg("Can't create probe event.", NULL);
		return 0;
	}

	probe = (IonProbe *) psp(ionwm, addr);
	CHKZERO(probe);
	probe->time = getUTCTime();
	probe->destNodeNbr = node->nodeNbr;
	probe->neighborNodeNbr = embargo->nodeNbr;

	/*	Schedule next probe of this embargoed neighbor for the
	 *	time that is the current time plus 2x the round-trip
	 *	light time from the local node to the neighbor (but
	 *	at least 6 seconds).					*/
	 
	ionvdb = getIonVdb();
	neighbor = findNeighbor(ionvdb, embargo->nodeNbr, &nextElt);
	if (neighbor)
	{
		rtlt = (neighbor->owltOutbound + neighbor->owltInbound) << 1;
		if (rtlt > interval)
		{
			interval = rtlt;
		}
	}

	probe->time += interval;
	for (elt = sm_list_last(ionwm, ionvdb->probes); elt;
			elt = sm_list_prev(ionwm, elt))
	{
		pr = (IonProbe *) psp(ionwm, sm_list_data(ionwm, elt));
		CHKZERO(pr);
		if (pr->time <= probe->time)
		{
			return sm_list_insert_after(ionwm, elt, addr);
		}
	}

	return sm_list_insert_first(ionwm, ionvdb->probes, addr);
}
开发者ID:michirod,项目名称:cgr-jni,代码行数:58,代码来源:rfx.c

示例8: Sm_list_insert

PsmAddress	Sm_list_insert(const char *fileName, int lineNbr,
			PsmPartition partition, PsmAddress list,
			PsmAddress data, SmListCompareFn compare, void *argData)
{
	SmList		*listBuffer;
	PsmAddress	elt;
	SmListElt	*eltBuffer;

	if (compare == (SmListCompareFn) NULL)
	{
		/*	List is assumed to be unsorted.  We simply
			add the new element at the end of the list.	*/

		return Sm_list_insert_last(fileName, lineNbr, partition,
				list, data);
	}

	/*	Using user-specified comparison function.  List is
		assumed to be in sorted order.				*/

	CHKZERO(partition);
	CHKZERO(list);
	listBuffer = (SmList *) psp(partition, list);
	CHKZERO(listBuffer);
	if (lockSmlist(listBuffer) == ERROR)
	{
		putErrmsg(_cannotLockMsg(), NULL);
		return 0;
	}

	/*	Find position to insert new data into list.
		Start from end of list to keep sort stable;
		sort sequence is implicitly FIFO within key,
		i.e., we insert element AFTER the last element
		in the table with the same key value.			*/

	for (elt = listBuffer->last; elt != 0; elt = eltBuffer->prev)
	{
		eltBuffer = (SmListElt *) psp(partition, elt);
		CHKZERO(eltBuffer);
		if (compare(partition, eltBuffer->data, argData) <= 0)
		{
			break;
		}
	}

	/* insert into list */

	if (elt == 0)
	{
		return finishInsertingFirst(fileName, lineNbr, partition, list,
				listBuffer, data);
	}

	return finishInsertingAfter(fileName, lineNbr, partition, elt,
			eltBuffer, list, listBuffer, data);
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:57,代码来源:smlist.c

示例9: Sm_list_insert_before

PsmAddress	Sm_list_insert_before(const char *fileName, int lineNbr,
			PsmPartition partition, PsmAddress oldElt,
			PsmAddress data)
{
	SmListElt	*oldEltBuffer;
	PsmAddress	list;
	SmList		*listBuffer;
	PsmAddress	elt;
	SmListElt	*eltBuffer;

	CHKZERO(partition);
	CHKZERO(oldElt);
	oldEltBuffer = (SmListElt *) psp(partition, oldElt);
	CHKZERO(oldEltBuffer);
	if ((list = oldEltBuffer->list) == 0)
	{
		putErrmsg(_noListMsg(), NULL);
		return 0;
	}

	listBuffer = (SmList *) psp(partition, list);
	if (lockSmlist(listBuffer) == ERROR)
	{
		putErrmsg(_cannotLockMsg(), NULL);
		return 0;
	}

	elt = Psm_zalloc(fileName, lineNbr, partition, sizeof(SmListElt));
	if (elt == 0)
	{
		unlockSmlist(listBuffer);
		putErrmsg(_noSpaceForEltMsg(), NULL);
		return 0;
	}

	eltBuffer = (SmListElt *) psp(partition, elt);
	eraseListElt(eltBuffer);
	eltBuffer->list = list;
	eltBuffer->data = data;
	eltBuffer->prev = oldEltBuffer->prev;
	eltBuffer->next = oldElt;
	if (oldEltBuffer->prev != 0)
	{
		eltBuffer = (SmListElt *) psp(partition, oldEltBuffer->prev);
		CHKZERO(eltBuffer);
		eltBuffer->next = elt;
	}
	else
	{
		listBuffer->first = elt;
	}

	oldEltBuffer->prev = elt;
	listBuffer->length += 1;
	unlockSmlist(listBuffer);
	return elt;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:57,代码来源:smlist.c

示例10: sptrace_log_free

void	sptrace_log_free(PsmPartition trace, unsigned long addr,
		char *fileName, int lineNbr)
{
	PsmAddress	elt;
	TraceItem	*item;
	TraceItem	*refitem;

	if (!trace) return;
	logEvent(trace, OP_FREE, addr, -1, NULL, fileName, lineNbr, &elt);
	if (elt)	/*	Event was logged.			*/
	{
		item = (TraceItem *) psp(trace, sm_list_data(trace, elt));

		/*	Find matching allocation, close it out.		*/

		elt = sm_list_prev(trace, elt);
		while (elt)
		{
			refitem = (TraceItem *) psp(trace,
					sm_list_data(trace, elt));
			CHKVOID(refitem);
			if (refitem->objectAddress != item->objectAddress)
			{
				elt = sm_list_prev(trace, elt);
				continue;
			}

			/*	Found match.				*/

			switch (refitem->opType)
			{
			case OP_MEMO:	/*	Ignore it.		*/
				elt = sm_list_prev(trace, elt);
				continue;

			case OP_FREE:	/*	Duplicate free.		*/
				return;
			}

			/*	Found most recent open allocation.	*/

			item->refTaskId = refitem->taskId;
			item->refFileName = refitem->fileName;
			item->refLineNbr = refitem->lineNbr;
			item->refOpNbr = refitem->opNbr;
			item->objectSize = refitem->objectSize;
			refitem->refTaskId = item->taskId;
			refitem->refFileName = item->fileName;
			refitem->refLineNbr = item->lineNbr;
			refitem->refOpNbr = item->opNbr;
			return;
		}
	}
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:54,代码来源:sptrace.c

示例11: treeBroken

int	treeBroken(PsmPartition partition, PsmAddress rbt)
{
	SmRbt	*rbtPtr;

	rbtPtr = (SmRbt *) psp(partition, rbt);
	return (subtreeBlackHeight(partition, rbtPtr->root) == 0);
}
开发者ID:NASAHackTO,项目名称:ion-dtn,代码行数:7,代码来源:smrbt.c

示例12: DOS_FCBOpen

bool DOS_FCBOpen(Bit16u seg,Bit16u offset) { 
	DOS_FCB fcb(seg,offset);
	char shortname[DOS_FCBNAME];Bit16u handle;
	fcb.GetName(shortname);

	/* First check if the name is correct */
	Bit8u drive;
	char fullname[DOS_PATHLENGTH];
	if (!DOS_MakeName(shortname,fullname,&drive)) return false;
	
	/* Check, if file is already opened */
	for (Bit8u i=0;i<DOS_FILES;i++) {
		DOS_PSP psp(dos.psp());
		if (Files[i] && Files[i]->IsOpen() && Files[i]->IsName(fullname)) {
			handle = psp.FindEntryByHandle(i);
			if (handle==0xFF) {
				// This shouldnt happen
				LOG(LOG_FILES,LOG_ERROR)("DOS: File %s is opened but has no psp entry.",shortname);
				return false;
			}
			fcb.FileOpen((Bit8u)handle);
			return true;
		}
	}
	
	if (!DOS_OpenFile(shortname,OPEN_READWRITE,&handle)) return false;
	fcb.FileOpen((Bit8u)handle);
	return true;
}
开发者ID:Avin15,项目名称:dospad,代码行数:29,代码来源:dos_files.cpp

示例13: DOS_DuplicateEntry

bool DOS_DuplicateEntry(Bit16u entry,Bit16u * newentry) {
    // Dont duplicate console handles
    /*	if (entry<=STDPRN) {
    		*newentry = entry;
    		return true;
    	};
    */
    Bit8u handle=RealHandle(entry);
    if (handle>=DOS_FILES) {
        DOS_SetError(DOSERR_INVALID_HANDLE);
        return false;
    };
    if (!Files[handle] || !Files[handle]->IsOpen()) {
        DOS_SetError(DOSERR_INVALID_HANDLE);
        return false;
    };
    DOS_PSP psp(dos.psp());
    *newentry = psp.FindFreeFileEntry();
    if (*newentry==0xff) {
        DOS_SetError(DOSERR_TOO_MANY_OPEN_FILES);
        return false;
    }
    Files[handle]->AddRef();
    psp.SetFileHandle(*newentry,handle);
    return true;
}
开发者ID:svn2github,项目名称:dosbox,代码行数:26,代码来源:dos_files.cpp

示例14: removeEmbargo

void	removeEmbargo(IonNode *node, uvast neighborNodeNbr)
{
	PsmPartition	ionwm = getIonwm();
	PsmAddress	elt;
	PsmAddress	addr;
	Embargo		*embargo;

	CHKVOID(node);
	for (elt = sm_list_first(ionwm, node->embargoes); elt;
			elt = sm_list_next(ionwm, elt))
	{
		addr = sm_list_data(ionwm, elt);
		embargo = (Embargo *) psp(ionwm, addr);
		CHKVOID(embargo);
		if (embargo->nodeNbr < neighborNodeNbr)
		{
			continue;
		}

		if (embargo->nodeNbr > neighborNodeNbr)
		{
			return;	/*	Embargo not found.		*/
		}

		break;		/*	Found the embargo to remove.	*/
	}

	if (elt == 0)
	{
		return;		/*	Embargo not found.		*/
	}

	oK(sm_list_delete(ionwm, elt, NULL, NULL));
	psm_free(ionwm, addr);
}
开发者ID:michirod,项目名称:cgr-jni,代码行数:35,代码来源:rfx.c

示例15: Sm_list_create

PsmAddress	Sm_list_create(const char *fileName, int lineNbr,
			PsmPartition partition)
{
	sm_SemId	lock;
	PsmAddress	list;
	SmList		*listBuffer;

	lock = sm_SemCreate(SM_NO_KEY, SM_SEM_FIFO);
	if (lock < 0)
	{
		putErrmsg("Can't create semaphore for list.", NULL);
		return 0;
	}

	list = Psm_zalloc(fileName, lineNbr, partition, sizeof(SmList));
	if (list == 0)
	{
		sm_SemDelete(lock);
		putErrmsg("Can't allocate space for list header.", NULL);
		return 0;
	}

	listBuffer = (SmList *) psp(partition, list);
	eraseList(listBuffer);
	listBuffer->lock = lock;
	return list;
}
开发者ID:brnrc,项目名称:ion-dtn,代码行数:27,代码来源:smlist.c


注:本文中的psp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。