Home | History | Annotate | Download | only in vm

Lines Matching refs:mon

97     Monitor* mon;
99 mon = (Monitor*) calloc(1, sizeof(Monitor));
100 if (mon == NULL) {
104 mon->obj = obj;
105 dvmInitMutex(&mon->lock);
109 mon->next = gDvm.monitorList;
110 } while (android_atomic_release_cas((int32_t)mon->next, (int32_t)mon,
113 return mon;
121 Monitor* mon;
124 mon = gDvm.monitorList;
125 while (mon != NULL) {
126 nextMon = mon->next;
127 free(mon);
128 mon = nextMon;
135 Object* dvmGetMonitorObject(Monitor* mon)
137 if (mon == NULL)
140 return mon->obj;
197 static void freeMonitor(Monitor *mon)
199 assert(mon != NULL);
200 assert(mon->obj != NULL);
201 assert(LW_SHAPE(mon->obj->lock) == LW_SHAPE_FAT);
210 assert(pthread_mutex_trylock(&mon->lock) == 0);
211 assert(pthread_mutex_unlock(&mon->lock) == 0);
212 dvmDestroyMutex(&mon->lock);
213 free(mon);
219 void dvmSweepMonitorList(Monitor** mon, int (*isUnmarkedObject)(void*))
225 assert(mon != NULL);
228 prev->next = curr = *mon;
240 *mon = handle.next;
343 static void lockMonitor(Thread* self, Monitor* mon)
349 if (mon->owner == self) {
350 mon->lockCount++;
353 if (dvmTryLockMutex(&mon->lock) != 0) {
360 const Method* currentOwnerMethod = mon->ownerMethod;
361 u4 currentOwnerPc = mon->ownerPc;
363 dvmLockMutex(&mon->lock);
390 mon->owner = self;
391 assert(mon->lockCount == 0);
396 mon->ownerMethod = NULL;
397 mon->ownerPc = 0;
405 mon->ownerMethod = saveArea->method;
406 mon->ownerPc = (saveArea->xtra.currentPc - saveArea->method->insns);
416 static bool tryLockMonitor(Thread* self, Monitor* mon)
418 if (mon->owner == self) {
419 mon->lockCount++;
422 if (dvmTryLockMutex(&mon->lock) == 0) {
423 mon->owner = self;
424 assert(mon->lockCount == 0);
439 static bool unlockMonitor(Thread* self, Monitor* mon)
442 assert(mon != NULL);
443 if (mon->owner == self) {
447 if (mon->lockCount == 0) {
448 mon->owner = NULL;
449 mon->ownerMethod = NULL;
450 mon->ownerPc = 0;
451 dvmUnlockMutex(&mon->lock);
453 mon->lockCount--;
472 static int waitSetCheck(Monitor *mon)
477 assert(mon != NULL);
478 fast = slow = mon->waitSet;
495 static void waitSetAppend(Monitor *mon, Thread *thread)
499 assert(mon != NULL);
500 assert(mon->owner == dvmThreadSelf());
503 assert(waitSetCheck(mon) == 0);
504 if (mon->waitSet == NULL) {
505 mon->waitSet = thread;
508 elt = mon->waitSet;
519 static void waitSetRemove(Monitor *mon, Thread *thread)
523 assert(mon != NULL);
524 assert(mon->owner == dvmThreadSelf());
526 assert(waitSetCheck(mon) == 0);
527 if (mon->waitSet == NULL) {
530 if (mon->waitSet == thread) {
531 mon->waitSet = thread->waitNext;
535 elt = mon->waitSet;
616 static void waitMonitor(Thread* self, Monitor* mon, s8 msec, s4 nsec,
625 assert(mon != NULL);
628 if (mon->owner != self) {
662 waitSetAppend(mon, self);
663 int prevLockCount = mon->lockCount;
664 mon->lockCount = 0;
665 mon->owner = NULL;
667 const Method* savedMethod = mon->ownerMethod;
668 u4 savedPc = mon->ownerPc;
669 mon->ownerMethod = NULL;
670 mon->ownerPc = 0;
690 self->waitMonitor = mon;
707 dvmUnlockMutex(&mon->lock);
730 lockMonitor(self, mon);
739 mon->owner = self;
740 mon->lockCount = prevLockCount;
741 mon->ownerMethod = savedMethod;
742 mon->ownerPc = savedPc;
743 waitSetRemove(mon, self);
766 static void notifyMonitor(Thread* self, Monitor* mon)
771 assert(mon != NULL);
774 if (mon->owner != self) {
780 while (mon->waitSet != NULL) {
781 thread = mon->waitSet;
782 mon->waitSet = thread->waitNext;
798 static void notifyAllMonitor(Thread* self, Monitor* mon)
803 assert(mon != NULL);
806 if (mon->owner != self) {
812 while (mon->waitSet != NULL) {
813 thread = mon->waitSet;
814 mon->waitSet = thread->waitNext;
831 Monitor *mon;
839 mon = dvmCreateMonitor(obj);
840 lockMonitor(self, mon);
843 mon->lockCount = LW_LOCK_COUNT(thin);
845 thin |= (u4)mon | LW_SHAPE_FAT;
1069 Monitor* mon;
1091 mon = LW_MONITOR(obj->lock);
1092 waitMonitor(self, mon, msec, nsec, interruptShouldThrow);
1168 Monitor* mon = gDvm.threadSleepMon;
1174 lockMonitor(self, mon);
1175 waitMonitor(self, mon, msec, nsec, true);
1176 unlockMonitor(self, mon);