本文整理汇总了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);
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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. */
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
}
示例11: treeBroken
int treeBroken(PsmPartition partition, PsmAddress rbt)
{
SmRbt *rbtPtr;
rbtPtr = (SmRbt *) psp(partition, rbt);
return (subtreeBlackHeight(partition, rbtPtr->root) == 0);
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}