/** Registeres current VM task to get notifications on record store changes */ void rms_registry_start_record_store_listening(int suiteId, pcsl_string *storeName) { RecordStoreListener *listenerPtr; int taskId = getCurrentIsolateId(); /* Cache maximal VM tasks number on first demand */ if (maxTasks == 0) { maxTasks = getMaxIsolates(); } /* Search for existing listener entry to update listener ID */ listenerPtr = findRecordStoreListener(suiteId, storeName); if (listenerPtr != NULL) { int i, count; count = listenerPtr->count; for (i = 0; i < count; i++) { if (listenerPtr->listenerId[i] == taskId) { return; } } if (count >= maxTasks) { REPORT_CRIT(LC_RMS, "rms_registry_start_record_store_listening: " "internal structure overflow"); return; } listenerPtr->listenerId[count] = taskId; listenerPtr->count = count + 1; return; } /* Create new listener entry for record store */ createListenerNode(suiteId, storeName, taskId); }
/** * Initializes the event system. * <p> * <b>NOTE:</b> The event system must be explicitly initialize so the * VM can shutdown and restart cleanly. * * @return 0 for success, or non-zero if the MIDP implementation is * out of memory */ int InitializeEvents(void) { int sizeInBytes; if (NULL != gsEventQueues) { /* already done */ return 0; } #if ENABLE_MULTIPLE_ISOLATES gsMaxIsolates = getMaxIsolates(); /* * In MVM the first isolate has number 1, but 0 still can be returned * by midpGetAmsIsolate() if JVM is not running. So in MVM we allocate * one more entry in gsEventQueues[] to make indices from 0 to maxIsolates * inclusively valid. */ gsTotalQueues = gsMaxIsolates + 1; #else gsTotalQueues = 1; #endif #if ENABLE_EVENT_SPYING gsEventSpyingQueueId = gsTotalQueues; gsTotalQueues += 1; #endif sizeInBytes = gsTotalQueues * sizeof (EventQueue); gsEventQueues = midpMalloc(sizeInBytes); if (NULL == gsEventQueues) { return -1; } memset(gsEventQueues, 0, sizeInBytes); midp_createEventQueueLock(); return 0; }
/** * Reads JAVA_HEAP_SIZE property and returns it as required heap size. * If JAVA_HEAP_SIZE has not been found, then reads MAX_ISOLATES property, * calculates and returns size of the required heap. If the MAX_ISOLATES * has not been found, default heap size is returned. * * @return <tt>heap size</tt> */ int getHeapRequirement() { int maxIsolates; int midpHeapRequirement; midpHeapRequirement = getInternalPropertyInt("JAVA_HEAP_SIZE"); if (midpHeapRequirement > 0) { return midpHeapRequirement; } maxIsolates = getMaxIsolates(); /* * Calculate heap size. * * IMPL_NOTE: bellow ENABLE_NATIVE_APP_MANAGER value is checked instead of * moving this part into a separate library * (for ex., ams/example/ams_parameters) * because currently amount of memory needed for AMS isolate is the only * property that has different values for JAMS and NAMS. If new such values * are added, a new library should be introduced. */ #if ENABLE_NATIVE_APP_MANAGER /* * Actually, when using NAMS, AMS isolate requires less then 1024K memory, * so the value bellow can be tuned for each particular project. */ midpHeapRequirement = maxIsolates * 1024 * 1024; #else /* * In JAMS AMS isolate requires a little bit more memory because * it holds skin images that are shared among all isolates. */ midpHeapRequirement = 1280 * 1024 + (maxIsolates - 1) * 1024 * 1024; #endif return midpHeapRequirement; }
/** * Get maximal number of Isolates allowed by AMS * @return maximal Isolates number */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(com_sun_midp_main_MIDletSuiteUtils_getMaxIsolates) { KNI_ReturnInt(getMaxIsolates()); }