コード例 #1
0
ファイル: mtree.c プロジェクト: sourceops/ceptr
// helper function to recursively travers a ttree and build an mtree out of it
// used by _m_new_from_t
H __mnft(H parent,T *t) {
    int i, c = _t_children(t);
    H h = _m_new(parent,_t_symbol(t),_t_surface(t),_t_size(t));
    for(i=1;i<=c;i++) {
    __mnft(h,_t_child(t,i));
    }
    return h;
}
コード例 #2
0
ファイル: accumulator.c プロジェクト: ChunHungLiu/ceptr
/**
 * clean shutdown of the the ceptr system
 *
 * should be called by the thread that called _a_boot() (or _a_start_vmhost())
 */
void _a_shut_down() {
    // cleanly close down any processing in the VM_Host
    __r_kill(G_vm->r);

    _v_join_thread(&G_vm->clock_thread);
    _v_join_thread(&G_vm->vm_thread);

    char fn[1000];

    // serialize the semtable
    __a_serializet(_t_root(G_vm->sem->stores[0].definitions),SEM_FN);

    int i;
    T *paths = _t_new_root(RECEPTOR_PATHS);
    for (i=0;i<G_vm->sem->contexts;i++) { // we don't need the path of the root so start at 1
        int *p = _t_get_path(G_vm->sem->stores[i].definitions);
        if (p) {
            _t_new(paths,RECEPTOR_PATH,p,sizeof(int)*(_t_path_depth(p)+1));
            free(p);
        }
        else
            _t_newr(paths,STRUCTURE_ANYTHING); // should be something like DELETED_CONTEXT
    }
    __a_serializet(paths,PATHS_FN);
    _t_free(paths);

    // serialize the receptor part of the vmhost
    void *surface;
    size_t length;
    _r_serialize(G_vm->r,&surface,&length);
    //    _r_unserialize(surface);
    __a_vmfn(fn,G_vm->dir);
    writeFile(fn,surface,length);
    free(surface);

    // serialize other parts of the vmhost
    H h = _m_newr(null_H,SYS_STATE);
    H har = _m_newr(h,ACTIVE_RECEPTORS);
    for (i=0;i<G_vm->active_receptor_count;i++) {
        _m_new(har,RECEPTOR_XADDR,&G_vm->active_receptors[i].x,sizeof(Xaddr));
    }
    S *s = _m_serialize(h.m);
    __a_vm_state_fn(fn,G_vm->dir);
    writeFile(fn,s,s->total_size);
    free(s);
    _m_free(h);

    // free the memory used by the SYS_RECEPTOR
    _v_free(G_vm);
    G_vm = NULL;
}
コード例 #3
0
ファイル: mtree.c プロジェクト: tropology/ceptr
/**
 * Create a new mtree node with an integer surface
 *
 * @param[in] parent parent node handle for the node to be created.  Can be 0 if this is a root node
 * @param[in] symbol semantic symbol for the node to be create
 * @param[in] surface integer value to store in the surface
 * @returns handle to node
 */
H _m_newi(H parent,Symbol symbol,int surface) {
    return _m_new(parent,symbol,&surface,sizeof(int));
}
コード例 #4
0
ファイル: mtree.c プロジェクト: tropology/ceptr
/**
 * Create a new mtree node with no surface value
 *
 * @param[in] parent parent node handle for the node to be created.  Can be 0 if this is a root node
 * @param[in] symbol semantic symbol for the node to be create
 * @returns handle to node
 */
H _m_newr(H parent,Symbol s) {
    return _m_new(parent,s,0,0);
}
コード例 #5
0
ファイル: mtree.c プロジェクト: tropology/ceptr
/**
 * Create a new tree
 *
 * @param[in] symbol semantic symbol for the node to be created
 * @returns handle to root node
 */
H _m_new_root(Symbol s) {
    return _m_new(null_H,s,0,0);
}