Package org.jnode.vm.scheduler

Examples of org.jnode.vm.scheduler.Monitor


     * @param heapManager
     */
    public FinalizerThread(DefaultHeapManager heapManager) {
        super("finalizer-thread");
        this.heapManager = heapManager;
        this.monitor = new Monitor();
        this.visitor = new FinalizerVisitor(heapManager.getHelper());
    }
View Full Code Here


            }
        } else {
            verifyObject(object, (VmNormalClass) vmClass);
        }
        verifyChild(VmMagic.getTIB(object), object, "tib");
        final Monitor monitor = helper.getInflatedMonitor(object, arch);
        if (monitor != null) {
            verifyChild(monitor, object, "monitor");
        }
        return (errorCount == 0);
    }
View Full Code Here

                }
            } else {
                markObject(object, (VmNormalClass) vmClass);
            }
            processChild(VmMagic.getTIB(object));
            final Monitor monitor = helper.getInflatedMonitor(object, arch);
            if (monitor != null) {
                processChild(monitor);
            }
            final int gcColor = VmMagic.getObjectColor(object);
            helper.atomicChangeObjectColor(object, gcColor, GC_BLACK);
View Full Code Here

        heapList = gcHeap;
    }

    public void start() {
        // Create a Heap monitor
        heapMonitor = new Monitor();
        final BaseVmArchitecture arch = getCurrentProcessor().getArchitecture();
        this.gcManager = new GCManager(this, arch);
        this.gcThread = new GCThread(gcManager, heapMonitor);
        this.finalizerThread = new FinalizerThread(this);
        gcThread.start();
View Full Code Here

        VmDefaultHeap heap = currentHeap;
        Object result = null;
        int oomCount = 0;

        final Monitor m = heapMonitor;
        // final Monitor m = null;
        if (m != null) {
            m.enter();
        }
        try {
            if (gcActive) {
                if ((heapFlags & TRACE_ALLOC) != 0) {
                    debug("Using GC Heap type ");
                    debug(vmClass.getName());
                }
                result = gcHeap.alloc(vmClass, alignedSize);
                if (result == null) {
                    helper.die("Out of GC heap memory.");
                }
            } else {
                while (result == null) {
                    // The current heap is full
                    if (heap == null) {
                        // Unsafe.debug("allocHeap in allocObject(");
                        // Unsafe.debug(alignedSize);
                        // Unsafe.debug(") ");
                        int newHeapSize = DEFAULT_HEAP_SIZE;
                        if (size > newHeapSize) {
                            // this is a BIG object, try to allocate a new
                            // heap
                            // only for it
                            newHeapSize = size;
                        }
                        if ((heap = allocHeap(Extent
                            .fromIntZeroExtend(newHeapSize), true)) == null) {
                            lowOnMemory = true;
                            // It was not possible to allocate another heap.
                            // First try to GC, if we've done that before
                            // in this allocation, then we're in real panic.
                            if (oomCount == 0) {
                                oomCount++;
                                if ((heapFlags & TRACE_OOM) != 0) {
                                    debug("<oom/>");
                                }
                                gcThread.trigger(true);
                                heap = firstNormalHeap;
                                currentHeap = firstNormalHeap;
                            } else {
                                if ((heapFlags & TRACE_OOM) != 0) {
                                    debug("Out of memory in allocObject(");
                                    debug(size);
                                    debug(")");
                                }
                                throw OOME;
                                // Unsafe.die();
                            }
                        } else {
                            // Unsafe.debug("AO.G");
                            // We successfully allocated a new heap, set it
                            // to current, so we'll use it for the following
                            // allocations.
                            currentHeap = heap;
                        }
                    }

                    result = heap.alloc(vmClass, alignedSize);

                    if (result == null) {
                        heap = (VmDefaultHeap) heap.getNext();
                    }
                }
                lowOnMemory = false;

                allocatedSinceGcTrigger += alignedSize;
                if ((allocatedSinceGcTrigger > triggerSize)
                    && (gcThread != null)) {
                    if ((heapFlags & TRACE_TRIGGER) != 0) {
                        debug("<alloc:GC trigger/>");
                    }
                    allocatedSinceGcTrigger = 0;
                    gcThread.trigger(false);
                }
            }
            vmClass.incInstanceCount();
            // Allocated objects are initially black.
            VmMagic.setObjectFlags(result, Word
                .fromIntZeroExtend(ObjectFlags.GC_DEFAULT_COLOR));
        } finally {
            if (m != null) {
                m.exit();
            }
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.jnode.vm.scheduler.Monitor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.