示例#1
0
static void remove_vm_thread_from_list(pvm_object_storage_t *os)
{
    // TODO check that is is a thread

    int nthreads  = get_array_size(pvm_root.threads_list.data);

    if( !nthreads )
        SHOW_ERROR0( 0, "There were 0 live threads in image, and some thread is dead. Now -1?" );

    int nkill = 0;
    while(nthreads--)
    {
        struct pvm_object th =  pvm_get_array_ofield(pvm_root.threads_list.data, nthreads );
        pvm_check_is_thread( th );
        if( th.data == os )
        {
            pvm_set_array_ofield(pvm_root.threads_list.data, nthreads, pvm_create_null_object() );
            nkill++;
        }
    }

    if(1 != nkill)
        printf("Nkill = %d\n", nkill);
}
示例#2
0
int vm_syscall_block( pvm_object_t this, struct data_area_4_thread *tc, pvm_object_t (*syscall_worker)( pvm_object_t , struct data_area_4_thread *, int nmethod, pvm_object_t arg ) )
{

    // NB args must be popped before we push retcode

    int n_param = POP_ISTACK;
    CHECK_PARAM_COUNT(n_param, 2);

    //if( n_param < 1 ) SYSCALL_THROW(pvm_create_string_object( "blocking: need at least 1 parameter" ));

    int nmethod = POP_INT();
    pvm_object_t arg = POP_ARG;

    // push zero to obj stack

    pvm_ostack_push( tc->_ostack, pvm_create_null_object() ); 

    pvm_exec_save_fast_acc(tc); // Before snap

    if(phantom_virtual_machine_stop_request)
    {
        SHOW_FLOW0( 5, "VM thread will die now");
        hal_exit_kernel_thread();
    }

#if NEW_SNAP_SYNC
    snap_unlock();
#else
    SHOW_FLOW0( 15, "VM thread will sleep for blocking syscall");
    hal_mutex_lock( &interlock_mutex );