Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 47170 invoked from network); 9 Feb 2008 14:03:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Feb 2008 14:03:07 -0000 Received: (qmail 10372 invoked by uid 500); 9 Feb 2008 14:02:59 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 10347 invoked by uid 500); 9 Feb 2008 14:02:59 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 10338 invoked by uid 99); 9 Feb 2008 14:02:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Feb 2008 06:02:59 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of gshimansky@gmail.com designates 209.85.198.186 as permitted sender) Received: from [209.85.198.186] (HELO rv-out-0910.google.com) (209.85.198.186) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 09 Feb 2008 14:02:28 +0000 Received: by rv-out-0910.google.com with SMTP id k20so3017825rvb.0 for ; Sat, 09 Feb 2008 06:02:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=KpkpwQ1CH0dUacVV4g58mXI6J0anOQotxoMpOPC4ID4=; b=kN42hS6Qii/qdpzhnvWWMdXw4RmvCaxpx/pS805SBwRwuSKkDmy9iifXVraDXIsjMjSUVD5WDEg7SmDr5DjNNHYJrZUWurUmSqCZy9KvtebIlh3v7wvv4kUaEt8iES3XE/5opIWGPBOGX7Zv2puxetAIdobrRAR2vNWsXUe8TEQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=bKyfzz6TY6nLhpgiFN/5MgZwUfScG2ehEEieEuO1AQOwUDGktbX+RNPJiVPYuK/1H/2tqn2wqwh3h4R7xqX5QUF9jzx/G9b3w4Zn07QnGsooA7W3PaXP6uUPoxC0BSxuCapGiiWn/Yqpym7bAc2tQSNlRpQFeCl/KqVqMh67ZDs= Received: by 10.141.141.3 with SMTP id t3mr3993831rvn.226.1202565755318; Sat, 09 Feb 2008 06:02:35 -0800 (PST) Received: from ?127.0.0.1? ( [140.211.11.9]) by mx.google.com with ESMTPS id k2sm24324447rvb.36.2008.02.09.06.02.33 (version=SSLv3 cipher=RC4-MD5); Sat, 09 Feb 2008 06:02:34 -0800 (PST) Message-ID: <47ADB275.4060501@apache.org> Date: Sat, 09 Feb 2008 17:02:29 +0300 From: Gregory Shimansky User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: dev@harmony.apache.org Subject: Re: DestroyJavaVM, System.exit, etc References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Gregory Shimansky X-Virus-Checked: Checked by ClamAV on apache.org Alexei Fedotov said the following on 09.02.2008 16:34: > Hello, folks, > I have some problems trying to understand the current Harmony VM > shutdown mechanism. I would appreciate any help from you. > > * What is a correct place to put my own C shutdown code? It depends on how the application shuts down. It if finishes all non-daemon threads, then vm_destroy is a good place. Keep in mind that shutdown sequence is very fragile and it is easy to break it. If application exits with System.exit, then the only place is before _exit() in Java_java_lang_VMExecutionEngine_exit. > * Why does VM detach the main thread from both the launcher and > vm_destroy function? I didn't get the question. Do you mean that main thread is attached in the DestroyJavaVM function? It is done because at shutdown VM has to execute shutdown hooks, and therefore it has to execute Java on an attached thread. > * What is the reason for the global monitor locks and unlocks in > the following function? What means the comment about jobjectArray? > JNIEXPORT void JNICALL Java_java_lang_VMExecutionEngine_exit > (JNIEnv * jni_env, jclass, jint status, jboolean needFinalization, > jobjectArray) > { > // ToDo: process jobjectArray > hythread_global_lock(); > _exit(status); > hythread_global_unlock(); > } It was done to fix the bug HARMONY-5167. Somehow threads could be created even when _exit() function is executed, so final heap check could produce an error on windows in debug mode. > * Where are VM resources reclaimed on shutdown? I found the only > apr_pool_destroy(java_vm->pool) in DestroyJavaVM(). Are there any > other places? The main place is Global_Env::~Global_Env() in Environment.cpp. This destructor is called only in case VM exits normally. For System.exit destructors are not executed. -- Gregory