Re: [Sablevm-developer] Question about _svmf_stopping_java()
Brought to you by:
egagnon
From: Archie C. <ar...@de...> - 2004-01-18 20:15:10
|
Etienne Gagnon wrote: > > In _svmf_stopping_java(), if the current thread is in state > > SVM_THREAD_STATUS_HALT_REQUESTED you halt it by calling > > _svmf_halt_if_requested(). > > > > Is this really necessary? Couldn't you just change the thread's > > state to SVM_THREAD_STATUS_NOT_RUNNING_JAVA_RESUMING_DISALLOWED > > and let it continue? If it tries to return to Java mode later, > > then it would have to halt of course. > > Yes it is necessary. When a thread is in state > SVM_THREAD_STATUS_HALT_REQUESTED, there is another thread that would > like to GC, but has temporarily gone to sleep until all non-native > threads (in state SVM_THREAD_STATUS_HALT_REQUESTED) have reported > back and gone to sleep, allowing GC to proceed. Why wouldn't something like the following also work (ignoring synchronization in this example)? _svm_stopping_java() { if (env->thread_status == SVM_THREAD_STATUS_HALT_REQUESTED) { /* now there's one less thread running in java mode */ vm->pending_halt_thread_count--; /* were we the last java-mode thread to halt? */ if (vm->pending_halt_thread_count == 0) { /* yes, so signal requesting thread */ _svmm_cond_signal (vm->requesting_thread_cond); } } else assert(env->thread_status == SVM_THREAD_STATUS_RUNNING_JAVA); /* continue execution in native mode */ env->thread_status = SVM_THREAD_STATUS_NOT_RUNNING_JAVA_RESUMING_DISALLOWED; } However, I don't think this really gives you much advantage. It lets a thread continue in native mode instead of halting, but it probably is not going to get much further before having to come back to java mode and then halt anyway. Just a thought experiment really. -Archie __________________________________________________________________________ Archie Cobbs * Halloo Communications * http://www.halloo.com |