本文整理汇总了C++中dvmUnlockMutex函数的典型用法代码示例。如果您正苦于以下问题:C++ dvmUnlockMutex函数的具体用法?C++ dvmUnlockMutex怎么用?C++ dvmUnlockMutex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dvmUnlockMutex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dvmVisitRoots
/*
* Visits roots. TODO: visit cached global references.
*/
void dvmVisitRoots(RootVisitor *visitor, void *arg)
{
assert(visitor != NULL);
//u4 t0 = dvmGetRelativeTimeMsec();
#ifndef FASTIVA_PRELOAD_STATIC_INSTANCE
visitHashTable(visitor, gDvm.loadedClasses, ROOT_STICKY_CLASS, arg);
visitPrimitiveTypes(visitor, arg);
#endif
if (gDvm.dbgRegistry != NULL) {
visitHashTable(visitor, gDvm.dbgRegistry, ROOT_DEBUGGER, arg);
}
if (gDvm.literalStrings != NULL) {
visitHashTable(visitor, gDvm.literalStrings, ROOT_INTERNED_STRING, arg);
}
dvmLockMutex(&gDvm.jniGlobalRefLock);
visitIndirectRefTable(visitor, &gDvm.jniGlobalRefTable, 0, ROOT_JNI_GLOBAL, arg);
dvmUnlockMutex(&gDvm.jniGlobalRefLock);
dvmLockMutex(&gDvm.jniPinRefLock);
visitReferenceTable(visitor, &gDvm.jniPinRefTable, 0, ROOT_VM_INTERNAL, arg);
dvmUnlockMutex(&gDvm.jniPinRefLock);
visitThreads(visitor, arg);
(*visitor)(&gDvm.outOfMemoryObj, 0, ROOT_VM_INTERNAL, arg);
(*visitor)(&gDvm.internalErrorObj, 0, ROOT_VM_INTERNAL, arg);
(*visitor)(&gDvm.noClassDefFoundErrorObj, 0, ROOT_VM_INTERNAL, arg);
#ifdef FASTIVA
(*visitor)(&kernelData.g_pAnnotationsList, 0, ROOT_VM_INTERNAL, arg);
#endif
}
示例2: dvmHeapWorkerStartup
/*
* Crank up the heap worker thread.
*
* Does not return until the thread is ready for business.
*/
bool dvmHeapWorkerStartup(void)
{
assert(!gDvm.haltHeapWorker);
assert(!gDvm.heapWorkerReady);
assert(gDvm.heapWorkerHandle == 0);
assert(gDvm.heapWorkerInitialized);
/* use heapWorkerLock/heapWorkerCond to communicate readiness */
dvmLockMutex(&gDvm.heapWorkerLock);
//BUG: If a GC happens in here or in the new thread while we hold the lock,
// the GC will deadlock when trying to acquire heapWorkerLock.
if (!dvmCreateInternalThread(&gDvm.heapWorkerHandle,
"HeapWorker", heapWorkerThreadStart, NULL))
{
dvmUnlockMutex(&gDvm.heapWorkerLock);
return false;
}
/*
* Wait for the heap worker to come up. We know the thread was created,
* so this should not get stuck.
*/
while (!gDvm.heapWorkerReady) {
dvmWaitCond(&gDvm.heapWorkerCond, &gDvm.heapWorkerLock);
}
dvmUnlockMutex(&gDvm.heapWorkerLock);
return true;
}
示例3: dvmThreadInterrupt
/*
* Implement java.lang.Thread.interrupt().
*/
void dvmThreadInterrupt(Thread* thread)
{
assert(thread != NULL);
dvmLockMutex(&thread->waitMutex);
/*
* If the interrupted flag is already set no additional action is
* required.
*/
if (thread->interrupted == true) {
dvmUnlockMutex(&thread->waitMutex);
return;
}
/*
* Raise the "interrupted" flag. This will cause it to bail early out
* of the next wait() attempt, if it's not currently waiting on
* something.
*/
thread->interrupted = true;
/*
* Is the thread waiting?
*
* Note that fat vs. thin doesn't matter here; waitMonitor
* is only set when a thread actually waits on a monitor,
* which implies that the monitor has already been fattened.
*/
if (thread->waitMonitor != NULL) {
pthread_cond_signal(&thread->waitCond);
}
dvmUnlockMutex(&thread->waitMutex);
}
示例4: notifyMonitor
/*
* Notify one thread waiting on this monitor.
*/
static void notifyMonitor(Thread* self, Monitor* mon)
{
Thread* thread;
assert(self != NULL);
assert(mon != NULL);
/* Make sure that we hold the lock. */
if (mon->owner != self) {
dvmThrowIllegalMonitorStateException(
"object not locked by thread before notify()");
return;
}
/* Signal the first waiting thread in the wait set. */
while (mon->waitSet != NULL) {
thread = mon->waitSet;
mon->waitSet = thread->waitNext;
thread->waitNext = NULL;
dvmLockMutex(&thread->waitMutex);
/* Check to see if the thread is still waiting. */
if (thread->waitMonitor != NULL) {
pthread_cond_signal(&thread->waitCond);
dvmUnlockMutex(&thread->waitMutex);
return;
}
dvmUnlockMutex(&thread->waitMutex);
}
}
示例5: dvmCompilerUpdateGlobalState
void dvmCompilerUpdateGlobalState()
{
bool jitActive;
bool jitActivate;
bool needUnchain = false;
/*
* The tableLock might not be initialized yet by the compiler thread if
* debugger is attached from the very beginning of the VM launch. If
* pProfTableCopy is NULL, the lock is not initialized yet and we don't
* need to refresh anything either.
*/
if (gDvmJit.pProfTableCopy == NULL) {
return;
}
/*
* On the first enabling of method tracing, switch the compiler
* into a mode that includes trace support for invokes and returns.
* If there are any existing translations, flush them. NOTE: we
* can't blindly flush the translation cache because this code
* may be executed before the compiler thread has finished
* initialization.
*/
if ((gDvm.activeProfilers != 0) &&
!gDvmJit.methodTraceSupport) {
bool resetRequired;
/*
* compilerLock will prevent new compilations from being
* installed while we are working.
*/
dvmLockMutex(&gDvmJit.compilerLock);
gDvmJit.cacheVersion++; // invalidate compilations in flight
gDvmJit.methodTraceSupport = true;
resetRequired = (gDvmJit.numCompilations != 0);
dvmUnlockMutex(&gDvmJit.compilerLock);
if (resetRequired) {
dvmSuspendAllThreads(SUSPEND_FOR_CC_RESET);
resetCodeCache();
dvmResumeAllThreads(SUSPEND_FOR_CC_RESET);
}
}
dvmLockMutex(&gDvmJit.tableLock);
jitActive = gDvmJit.pProfTable != NULL;
jitActivate = !dvmDebuggerOrProfilerActive();
if (jitActivate && !jitActive) {
gDvmJit.pProfTable = gDvmJit.pProfTableCopy;
} else if (!jitActivate && jitActive) {
gDvmJit.pProfTable = NULL;
needUnchain = true;
}
dvmUnlockMutex(&gDvmJit.tableLock);
if (needUnchain)
dvmJitUnchainAll();
// Make sure all threads have current values
dvmJitUpdateThreadStateAll();
}
示例6: dvmCompilerWorkEnqueue
/*
* Attempt to enqueue a work order, returning true if successful.
*
* NOTE: Make sure that the caller frees the info pointer if the return value
* is false.
*/
bool dvmCompilerWorkEnqueue(const u2 *pc, WorkOrderKind kind, void* info)
{
int cc;
int i;
int numWork;
bool result = true;
dvmLockMutex(&gDvmJit.compilerLock);
/*
* Return if queue or code cache is full.
*/
if (gDvmJit.compilerQueueLength == COMPILER_WORK_QUEUE_SIZE ||
gDvmJit.codeCacheFull == true) {
dvmUnlockMutex(&gDvmJit.compilerLock);
return false;
}
for (numWork = gDvmJit.compilerQueueLength,
i = gDvmJit.compilerWorkDequeueIndex;
numWork > 0;
numWork--) {
/* Already enqueued */
if (gDvmJit.compilerWorkQueue[i++].pc == pc) {
dvmUnlockMutex(&gDvmJit.compilerLock);
return true;
}
/* Wrap around */
if (i == COMPILER_WORK_QUEUE_SIZE)
i = 0;
}
CompilerWorkOrder *newOrder =
&gDvmJit.compilerWorkQueue[gDvmJit.compilerWorkEnqueueIndex];
newOrder->pc = pc;
newOrder->kind = kind;
newOrder->info = info;
newOrder->result.methodCompilationAborted = false;
newOrder->result.codeAddress = NULL;
newOrder->result.discardResult =
(kind == kWorkOrderTraceDebug) ? true : false;
newOrder->result.cacheVersion = gDvmJit.cacheVersion;
newOrder->result.requestingThread = dvmThreadSelf();
gDvmJit.compilerWorkEnqueueIndex++;
if (gDvmJit.compilerWorkEnqueueIndex == COMPILER_WORK_QUEUE_SIZE)
gDvmJit.compilerWorkEnqueueIndex = 0;
gDvmJit.compilerQueueLength++;
cc = pthread_cond_signal(&gDvmJit.compilerQueueActivity);
assert(cc == 0);
dvmUnlockMutex(&gDvmJit.compilerLock);
return result;
}
示例7: dvmCompilerStartup
/**
* Jit编译器入口点函数
* @retval 0 表示失败
* @retval 1 表示成功
*/
bool dvmCompilerStartup(void)
{
/* 初始化一些线程同步方面的变量 */
dvmInitMutex(&gDvmJit.compilerLock);
dvmInitMutex(&gDvmJit.compilerICPatchLock);
dvmInitMutex(&gDvmJit.codeCacheProtectionLock);
dvmLockMutex(&gDvmJit.compilerLock);
pthread_cond_init(&gDvmJit.compilerQueueActivity, NULL);
pthread_cond_init(&gDvmJit.compilerQueueEmpty, NULL);
/* Reset the work queue */
/* 设置工作队列 */
gDvmJit.compilerWorkEnqueueIndex = gDvmJit.compilerWorkDequeueIndex = 0;
gDvmJit.compilerQueueLength = 0;
dvmUnlockMutex(&gDvmJit.compilerLock);
/*
* Defer rest of initialization until we're sure JIT'ng makes sense. Launch
* the compiler thread, which will do the real initialization if and
* when it is signalled to do so.
*/
/*
* 以下这个函数创建compilerThreadStart编译线程,当这条线程会执行真正的初始化工作
*/
return dvmCreateInternalThread(&gDvmJit.compilerHandle, "Compiler",
compilerThreadStart, NULL);
}
示例8: dvmLinearAllocDump
/*
* For debugging, dump the contents of a linear alloc area.
*
* We grab the lock so that the header contents and list output are
* consistent.
*/
void dvmLinearAllocDump(Object* classLoader)
{
#ifdef DISABLE_LINEAR_ALLOC
return;
#endif
LinearAllocHdr* pHdr = getHeader(classLoader);
dvmLockMutex(&pHdr->lock);
LOGI("LinearAlloc classLoader=%p\n", classLoader);
LOGI(" mapAddr=%p mapLength=%d firstOffset=%d\n",
pHdr->mapAddr, pHdr->mapLength, pHdr->firstOffset);
LOGI(" curOffset=%d\n", pHdr->curOffset);
int off = pHdr->firstOffset;
u4 rawLen, fullLen;
while (off < pHdr->curOffset) {
rawLen = *(u4*) (pHdr->mapAddr + off);
fullLen = ((HEADER_EXTRA*2 + (rawLen & LENGTHFLAG_MASK))
& ~(BLOCK_ALIGN-1));
LOGI(" %p (%3d): %clen=%d%s\n", pHdr->mapAddr + off + HEADER_EXTRA,
(int) ((off + HEADER_EXTRA) / PAGESIZE),
(rawLen & LENGTHFLAG_FREE) != 0 ? '*' : ' ',
rawLen & LENGTHFLAG_MASK,
(rawLen & LENGTHFLAG_RW) != 0 ? " [RW]" : "");
off += fullLen;
}
if (ENFORCE_READ_ONLY) {
LOGI("writeRefCount map:\n");
int numPages = (pHdr->mapLength+PAGESIZE-1) / PAGESIZE;
int zstart = 0;
int i;
for (i = 0; i < numPages; i++) {
int count = pHdr->writeRefCount[i];
if (count != 0) {
if (zstart < i-1)
printf(" %d-%d: zero\n", zstart, i-1);
else if (zstart == i-1)
printf(" %d: zero\n", zstart);
zstart = i+1;
printf(" %d: %d\n", i, count);
}
}
if (zstart < i)
printf(" %d-%d: zero\n", zstart, i-1);
}
LOGD("LinearAlloc %p using %d of %d (%d%%)\n",
classLoader, pHdr->curOffset, pHdr->mapLength,
(pHdr->curOffset * 100) / pHdr->mapLength);
dvmUnlockMutex(&pHdr->lock);
}
示例9: unlockMonitor
/*
* Unlock a monitor.
*
* Returns true if the unlock succeeded.
* If the unlock failed, an exception will be pending.
*/
static bool unlockMonitor(Thread* self, Monitor* mon)
{
assert(self != NULL);
assert(mon != NULL);
if (mon->owner == self) {
/*
* We own the monitor, so nobody else can be in here.
*/
if (mon->lockCount == 0) {
mon->owner = NULL;
mon->ownerMethod = NULL;
mon->ownerPc = 0;
dvmUnlockMutex(&mon->lock);
} else {
mon->lockCount--;
}
} else {
/*
* We don't own this, so we're not allowed to unlock it.
* The JNI spec says that we should throw IllegalMonitorStateException
* in this case.
*/
dvmThrowIllegalMonitorStateException("unlock of unowned monitor");
return false;
}
return true;
}
示例10: checkAllFree
/*
* Verify that all blocks are freed.
*
* This should only be done as we're shutting down, but there could be a
* daemon thread that's still trying to do something, so we grab the locks.
*/
static void checkAllFree(Object* classLoader)
{
#ifdef DISABLE_LINEAR_ALLOC
return;
#endif
LinearAllocHdr* pHdr = getHeader(classLoader);
dvmLockMutex(&pHdr->lock);
int off = pHdr->firstOffset;
u4 rawLen, fullLen;
while (off < pHdr->curOffset) {
rawLen = *(u4*) (pHdr->mapAddr + off);
fullLen = ((HEADER_EXTRA*2 + (rawLen & LENGTHFLAG_MASK))
& ~(BLOCK_ALIGN-1));
if ((rawLen & LENGTHFLAG_FREE) == 0) {
LOGW("LinearAlloc %p not freed: %p len=%d\n", classLoader,
pHdr->mapAddr + off + HEADER_EXTRA, rawLen & LENGTHFLAG_MASK);
}
off += fullLen;
}
dvmUnlockMutex(&pHdr->lock);
}
示例11: dvmDexChangeDex2
/*
Change the 2-byte value at the specified address to a new value. If the
location already has the new value, do nothing.
Otherwise works like dvmDexChangeDex1.
在指定位置改变一个双字节值为新值。如果该位置已经有新值,不作任何事情。
否则处理类似dvmDexChangeDex1。
*/
bool dvmDexChangeDex2(DvmDex* pDvmDex, u2* addr, u2 newVal)
{
if (*addr == newVal) {
ALOGV("+++ value at %p is already 0x%04x", addr, newVal);
return true;
}
/*
* We're not holding this for long, so we don't bother with switching
* to VMWAIT.
*/
dvmLockMutex(&pDvmDex->modLock);
ALOGV("+++ change 2byte at %p from 0x%04x to 0x%04x", addr, *addr, newVal);
if (sysChangeMapAccess(addr, 2, true, &pDvmDex->memMap) != 0) {
ALOGD("NOTE: DEX page access change (->RW) failed");
/* expected on files mounted from FAT; keep going (may crash) */
}
*addr = newVal;
if (sysChangeMapAccess(addr, 2, false, &pDvmDex->memMap) != 0) {
ALOGD("NOTE: DEX page access change (->RO) failed");
/* expected on files mounted from FAT; keep going */
}
dvmUnlockMutex(&pDvmDex->modLock);
return true;
}
示例12: lookupInternedString
static StringObject* lookupInternedString(StringObject* strObj, bool isLiteral)
{
StringObject* found;
assert(strObj != NULL);
u4 key = dvmComputeStringHash(strObj);
dvmLockMutex(&gDvm.internLock);
if (isLiteral) {
/*
* Check the literal table for a match.
*/
StringObject* literal = lookupString(gDvm.literalStrings, key, strObj);
if (literal != NULL) {
/*
* A match was found in the literal table, the easy case.
*/
found = literal;
} else {
/*
* There is no match in the literal table, check the
* interned string table.
*/
StringObject* interned = lookupString(gDvm.internedStrings, key, strObj);
if (interned != NULL) {
/*
* A match was found in the interned table. Move the
* matching string to the literal table.
*/
dvmHashTableRemove(gDvm.internedStrings, key, interned);
found = insertString(gDvm.literalStrings, key, interned);
assert(found == interned);
} else {
/*
* No match in the literal table or the interned
* table. Insert into the literal table.
*/
found = insertString(gDvm.literalStrings, key, strObj);
assert(found == strObj);
}
}
} else {
/*
* Check the literal table for a match.
*/
found = lookupString(gDvm.literalStrings, key, strObj);
if (found == NULL) {
/*
* No match was found in the literal table. Insert into
* the intern table if it does not already exist.
*/
found = insertString(gDvm.internedStrings, key, strObj);
}
}
assert(found != NULL);
dvmUnlockMutex(&gDvm.internLock);
return found;
}
示例13: gcDaemonShutdown
static void gcDaemonShutdown()
{
if (gHs->hasGcThread) {
dvmLockMutex(&gHs->gcThreadMutex);
gHs->gcThreadShutdown = true;
dvmSignalCond(&gHs->gcThreadCond);
dvmUnlockMutex(&gHs->gcThreadMutex);
pthread_join(gHs->gcThread, NULL);
}
}
示例14: dvmGcDetachDeadInternedStrings
/*
* Clear white references from the intern table.
*/
void dvmGcDetachDeadInternedStrings(int (*isUnmarkedObject)(void *))
{
/* It's possible for a GC to happen before dvmStringInternStartup()
* is called.
*/
if (gDvm.internedStrings != NULL) {
dvmLockMutex(&gDvm.internLock);
dvmHashForeachRemove(gDvm.internedStrings, isUnmarkedObject);
dvmUnlockMutex(&gDvm.internLock);
}
}
示例15: dvmIsWeakInternedString
/*
* Returns true if the object is a weak interned string. Any string
* interned by the user is weak.
*/
bool dvmIsWeakInternedString(StringObject* strObj)
{
assert(strObj != NULL);
if (gDvm.internedStrings == NULL) {
return false;
}
dvmLockMutex(&gDvm.internLock);
u4 key = dvmComputeStringHash(strObj);
StringObject* found = lookupString(gDvm.internedStrings, key, strObj);
dvmUnlockMutex(&gDvm.internLock);
return found == strObj;
}