void pvm_set_ofield( struct pvm_object op, unsigned int slot, struct pvm_object value ) { verify_o(op); verify_o(value); if( PHANTOM_OBJECT_STORAGE_FLAG_IS_INTERNAL & ((op.data)->_flags) ) { if( PHANTOM_OBJECT_STORAGE_FLAG_IS_RESIZEABLE & ((op.data)->_flags) ) { pvm_set_array_ofield( op.data, slot, value ); return; } pvm_exec_panic( "attempt to save to internal" ); } if( PHANTOM_OBJECT_STORAGE_FLAG_IS_IMMUTABLE & (op.data->_flags) ) pvm_exec_panic( "attempt to set_ofield for immutable" ); if( slot >= da_po_limit(op.data) ) { pvm_exec_panic( "slot index out of bounds" ); } if(da_po_ptr((op.data)->da)[slot].data) ref_dec_o(da_po_ptr((op.data)->da)[slot]); //decr old value da_po_ptr((op.data)->da)[slot] = value; }
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); }
// TODO need semaphores here void pvm_append_array(struct pvm_object_storage *array, struct pvm_object value_to_append ) { struct data_area_4_array *da = (struct data_area_4_array *)&(array->da); pvm_set_array_ofield(array, da->used_slots, value_to_append ); }