Beispiel #1
0
void activate_all_threads()
{
    int nthreads  = get_array_size(pvm_root.threads_list.data);

    if( nthreads == 0 )
        SHOW_ERROR0( 0, "There are 0 live threads in image, system must be dead :(" );

    SHOW_FLOW( 3, "Activating %d threads", nthreads);

    while(nthreads--)
    {
        struct pvm_object th =  pvm_get_array_ofield(pvm_root.threads_list.data, nthreads );
        pvm_check_is_thread( th );
        start_new_vm_thread( th );
    }

    all_threads_started = 1;
}
Beispiel #2
0
// TODO BUG XXX - races possible, read obj, then other thread writes
// to slot (derements refctr and kills object), then we attempt to
// use it (even increment refctr) -> death. Need atomic (to slot write? to refcnt dec?)
// refcnt incr here
struct pvm_object
pvm_get_ofield( struct pvm_object op, unsigned int slot )
{
    verify_o(op);
    if( PHANTOM_OBJECT_STORAGE_FLAG_IS_INTERNAL & ((op.data)->_flags) )
    {
        if( PHANTOM_OBJECT_STORAGE_FLAG_IS_RESIZEABLE & ((op.data)->_flags) )
        {
            return pvm_get_array_ofield( op.data, slot );
        }
        pvm_exec_panic( "attempt to load from internal" );
    }

    if( slot >= da_po_limit(op.data) )
    {
        pvm_exec_panic( "load: slot index out of bounds" );
    }

    verify_o(da_po_ptr((op.data)->da)[slot]);
    return da_po_ptr((op.data)->da)[slot];
}
Beispiel #3
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);
}