static inline void set_proviso_stack (wctx_t* ctx, alg_local_t* loc, cndfs_alg_local_t* cloc) { switch (cloc->successors) { case NONEC: bitvector_set (&loc->stackbits, pred(ctx, NOCYCLE)); break; case CYCLE: bitvector_unset (&loc->stackbits, pred(ctx, NOCYCLE)); break; case SRCINV: bitvector_set (&loc->stackbits, pred(ctx, INVOL)); break; default: HREassert (false); } }
static void free_block(uint32_t blockno) { /* EXERCISE: Your code here */ if(blockno > ospfs_super->os_firstinob + ospfs_super->os_ninodes/OSPFS_BLKINODES && blockno < ospfs_super->os_nblocks) bitvector_set(ospfs_block(OSPFS_FREEMAP_BLK),blockno); }
static bool check_cndfs_proviso (wctx_t *ctx) { alg_local_t *loc = ctx->local; if (PINS_POR == 0 || proviso != Proviso_CNDFS) return false; // Only check proviso if the state is volatile. It may be that: // - the reduced successor set is already involatile, or // - the proviso was checked before for this state, i.e. it is backtracked for the second time // Both imply that locally this thread visited all involatile successors if (bitvector_is_set(&loc->stackbits, cur(ctx,INVOL))) return false; bool no_cycle = bitvector_is_set (&loc->stackbits, cur(ctx,NOCYCLE)); cndfs_proviso_t prov = no_cycle ? VOLATILE : INVOLATILE; int success = state_store_try_set_counters (ctx->state->ref, 2, UNKNOWN, prov); if (( success && prov == INVOLATILE) || (!success && state_store_get_wip(ctx->state->ref) == INVOLATILE)) { bitvector_set (&loc->stackbits, cur(ctx,INVOL)); loc->counters.ignoring += success != 0; return true; } return false; }
static void free_block(uint32_t blockno) { /* EXERCISE: Your code here */ if(blockno < ospfs_super->os_firstinob) return; bitvector_set(ospfs_block(blockno / OSPFS_BLKBITSIZE + OSPFS_FREEMAP_BLK), blockno % OSPFS_BLKBITSIZE); }
static void free_block(uint32_t blockno) { void *bitmap = ospfs_block(OSPFS_FREEMAP_BLK); // TODO: check validity of block bitvector_set(bitmap, blockno); // mark as free (set i bit to 1) }
/* * walk from v toward a while keeping f (v) == 1 */ void walk (void *info, membership_t membership, bitvector *v, bitvector *a) { uscalar_t i; assert (bitvector_length (v) == bitvector_length (a)); i = bitvector_length (a) - 1; while (i > 0) { if (bitvector_get (v, i) != bitvector_get (a, i)) { bool b = bitvector_get (v, i); bitvector_set (v, i, !b); if ((*membership) (info, v)) { i = bitvector_length (a); } else { bitvector_set (v, i, b); } } i--; } }
static void free_block(uint32_t blockno) { /* DONE: Your code here */ // will not free boot, super, bitmap, or inode blocks if (blockno > ospfs_super->os_firstinob + OSPFS_BLKINODES){ void* bitvector = ospfs_block(OSPFS_FREEMAP_BLK); bitvector_set(bitvector, blockno); } return 0; }
static void free_block(uint32_t blockno) { /* EXERCISE: Your code here */ void* input_bitmap = ospfs_block(OSPFS_FREEMAP_BLK); int upperlimit = ospfs_super->os_nblocks; //make sure our blocknumber is within the bounds, then call set on that blocknumber if (blockno > OSPFS_FREEMAP_BLK && blockno < upperlimit) { bitvector_set(input_bitmap, blockno); } else printk("Error! Invalid block number to be freed\n"); }
static void free_block(uint32_t blockno) { /* EXERCISE: Your code here */ //might want to add in functionality so that it skips all inode blocks int min_blocks = ospfs_super->os_firstinob; void *bitmap = ospfs_block(OSPFS_FREEMAP_BLK); if(blockno > min_blocks && blockno < OSPFS_MAXFILEBLKS){ if(bitvector_test(bitmap, blockno) == 0){ bitvector_set(bitmap, blockno); } } }
/* NDFS dfs_blue */ void ndfs_blue (run_t *run, wctx_t *ctx) { alg_local_t *loc = ctx->local; transition_info_t ti = GB_NO_TRANSITION; ndfs_blue_handle (ctx, ctx->initial, &ti, 0); ctx->counters->trans = 0; //reset trans count while ( !run_is_stopped(run) ) { raw_data_t state_data = dfs_stack_top (loc->stack); if (NULL != state_data) { state_info_deserialize (ctx->state, state_data); nndfs_color_t color = nn_get_color (&loc->color_map, ctx->state->ref); if ( nn_color_eq(color, NNWHITE) ) { if (all_red) bitvector_set ( &loc->stackbits, ctx->counters->level_cur ); nn_set_color (&loc->color_map, ctx->state->ref, NNCYAN); ndfs_explore_state_blue (ctx); } else { if ( all_red && ctx->counters->level_cur != 0 && !nn_color_eq(color, NNPINK) ) bitvector_unset ( &loc->stackbits, ctx->counters->level_cur - 1); dfs_stack_pop (loc->stack); } } else { //backtrack if (0 == dfs_stack_nframes (loc->stack)) return; dfs_stack_leave (loc->stack); ctx->counters->level_cur--; state_data = dfs_stack_top (loc->stack); state_info_deserialize (loc->seed, state_data); if ( all_red && bitvector_is_set(&loc->stackbits, ctx->counters->level_cur) ) { /* exit if backtrack hits seed, leave stack the way it was */ nn_set_color (&loc->color_map, loc->seed->ref, NNPINK); loc->counters.allred++; if ( GBbuchiIsAccepting(ctx->model, state_info_state(loc->seed)) ) loc->counters.accepting++; } else if ( GBbuchiIsAccepting(ctx->model, state_info_state(loc->seed)) ) { /* call red DFS for accepting states */ ndfs_red (ctx, loc->seed->ref); nn_set_color (&loc->color_map, loc->seed->ref, NNPINK); } else { if (all_red && ctx->counters->level_cur > 0) bitvector_unset (&loc->stackbits, ctx->counters->level_cur - 1); nn_set_color (&loc->color_map, loc->seed->ref, NNBLUE); } dfs_stack_pop (loc->stack); } } }
static void free_block(uint32_t blockno) { /* EXERCISE: Your code here */ /* EXERCISE: Your code here */ if(blockno < ospfs_super->os_firstinob || blockno >= ospfs_super->os_nblocks) return; void *bitmap = ospfs_block(OSPFS_FREEMAP_BLK); /// bitvector_set -- Set 'i'th bit of 'vector' to 1. bitvector_set(bitmap, blockno); }
bitvector * gridfont_encodechar ( int *cells, int width, int height ) { bitvector *gchar = bitvector_init(width * height); for (int i = 0; i < width * height; i++) { if (cells[i] == 1) bitvector_set(gchar, i, 1); } return gchar; }
// gcc -Wall -O3 -DTEST_BIT_VECTOR bitvector.c && ./a.out int main() { const unsigned int nbits=40; bitvector_t b=bitvector_new(nbits); if (sizeof(int)!=4) { fprintf(stderr,"Size problem in bitvector.c"); exit(1); } bitvector_show(b,nbits); printf("\n"); bitvector_set(b,0); bitvector_set(b,1); bitvector_set(b,11); bitvector_set(b,38); bitvector_show(b,nbits); printf("\n"); bitvector_clear(b,38); bitvector_show(b,nbits); printf("\n"); bitvector_flip(b,0); bitvector_show(b,nbits); printf("\n"); bitvector_flip(b,0); bitvector_show(b,nbits); printf("\n"); printf("count_slow=%u\n",bitvector_count_slow(b,nbits)); printf("count=%u\n",bitvector_count(b,nbits)); bitvector_free(b); return 0; }
int dm_bitvector_col(bitvector_t *bv, const matrix_t *m, int col) { // check size if (bitvector_size (bv) != (size_t)dm_nrows (m)) return -1; // copy row for (int i = 0; i < dm_nrows (m); i++) { if (dm_is_set (m, i, col)) { bitvector_set(bv, i); } else { bitvector_unset(bv, i); } } return 0; }
static void free_block(uint32_t blockno) { unsigned* bitmap = &ospfs_data[OSPFS_FREEMAP_BLK]; //unsigned size_of_bitmap_bits = (ospfs_super->os_nblocks); unsigned nblocks_in_bitmap = ospfs_size2nblocks((ospfs_super->os_nblocks)/8); /* EXERCISE: Your code here */ if((blockno <= OSPFS_FREEMAP_BLK + nblocks_in_bitmap) || (blockno >= ospfs_super->os_nblocks)) { //do nothing return; } else { bitvector_set(bitmap, blockno); } }
void dm_set (matrix_t *m, int row, int col) { // get permutation int rowp = m->row_perm.data[row].becomes; int colp = m->col_perm.data[col].becomes; // calculate bit number int bitnr = rowp * (m->bits_per_row) + colp; // counts if (!bitvector_is_set (&(m->bits), bitnr)) { m->row_perm.count[rowp]++; m->col_perm.count[colp]++; } bitvector_set (&(m->bits), bitnr); }
void refine_bases (void *info, membership_t membership, membership_t comembership, vector *bases, int mode) { uscalar_t i, length; length = vector_length (bases); #ifdef DEBUG fprintf (stderr, "refine bases, num of DNF = %d",length); #endif for (i = 0; i < length; i++) { basis *B; bitvector *a_i; vector *T_i; uscalar_t l, T_i_len, j; bool b; B = (basis *) vector_get (bases, i); /* * extends each unsatisfying assignment by FALSE */ a_i = B->a; l = bitvector_length (a_i); bitvector_resize (a_i, l + 1); bitvector_set (a_i, l, false); if(mode==CDNF_PlusPlus) b = (*comembership) (info, a_i) == true ? false : true; else b=false; bitvector_set (a_i, l, b); #ifdef DEBUG fprintf (stderr, "extends basis: "); bitvector_print (a_i); #endif #ifdef DEBUG fprintf (stderr, "extends support: "); #endif T_i = B->T; T_i_len = vector_length (T_i); /* except the last basis, all bases have at least one support */ assert (i == length - 1 || T_i_len > 0); for (j = 0; j < T_i_len; j++) { bitvector *v; bool c; /* * extends v to v+b if MEM (v+b) = YES * to v+!b if MEM (v+b) = NO */ v = (bitvector *)vector_get (T_i, j); assert (bitvector_length (v) == l); bitvector_resize (v, l + 1); bitvector_set (v, l, b); c = (*membership) (info, v) == true ? b : !b; if (c != b) bitvector_set (v, l, c); #ifdef DEBUG bitvector_print (v); #endif } /* clean up disjunction for the current basis */ cdnfformula_disjunction_free (B->H); B->H = NULL; /* remove the last basis if it has no support */ if (T_i_len == 0) { assert (i == length - 1); bitvector_free (a_i); vector_free (T_i); free (vector_get (bases, length - 1)); vector_resize (bases, length - 1); } } /* * reconstruct disjunctions for the bases */ rebuild_disjunctions (bases); }
static void initialize_levels(bitvector_t *groups, int *empty_groups, int *back, bitvector_t *reach_groups) { int level[nGrps]; // groups: i = 0 .. nGrps - 1 // vars : j = 0 .. N - 1 // level[i] = first '+' in row (highest in BDD) of group i // recast 0 .. N - 1 down to equal groups 0 .. (N - 1) / sat_granularity for (int i = 0; i < nGrps; i++) { level[i] = -1; for (int j = 0; j < N; j++) { if (dm_is_set(GBgetDMInfo(model), i, j)) { level[i] = (N - j - 1) / sat_granularity; break; } } if (level[i] == -1) level[i] = 0; } for (int i = 0; i < nGrps; i++) bitvector_set(&groups[level[i]], i); // Limit the bit vectors to the groups we are interested in and establish // which saturation levels are not used. for (int k = 0; k < max_sat_levels; k++) { bitvector_intersect(&groups[k], reach_groups); empty_groups[k] = bitvector_is_empty(&groups[k]); } if (back == NULL) return; // back[k] = last + in any group of level k bitvector_t level_matrix[max_sat_levels]; for (int k = 0; k < max_sat_levels; k++) { bitvector_create(&level_matrix[k], N); back[k] = max_sat_levels; } for (int i = 0; i < nGrps; i++) { dm_row_union(&level_matrix[level[i]], GBgetDMInfo(model), i); } for (int k = 0; k < max_sat_levels; k++) { for (int j = 0; j < k; j++) { bitvector_t temp; int empty; bitvector_copy(&temp, &level_matrix[j]); bitvector_intersect(&temp, &level_matrix[k]); empty = bitvector_is_empty(&temp); bitvector_free(&temp); if (!empty) if (j < back[k]) back[k] = j; } if (back[k] == max_sat_levels && !bitvector_is_empty(&level_matrix[k])) back[k] = k + 1; } for (int k = 0; k < max_sat_levels; k++) bitvector_free(&level_matrix[k]); }
int main (void) { bitvector_t b1; bitvector_t b2; bitvector_create (&b1, 20); user_bitvector_print (&b1); bitvector_set (&b1, 4); user_bitvector_print (&b1); bitvector_copy (&b2, &b1); bitvector_unset (&b1, 4); user_bitvector_print (&b1); user_bitvector_print (&b2); // test is_empty printf ("is_empty b1? %c (should be t)\n", bitvector_is_empty(&b1)?'t':'f'); printf ("is_empty b2? %c (should be f)\n", bitvector_is_empty(&b2)?'t':'f'); // set even/odd bits in b1/b2 for(int i=0; i<20; ++i) { if (i%2) { bitvector_set(&b1,i); } else { bitvector_set(&b2,i); } } // print before union printf ("before union\n"); user_bitvector_print (&b1); user_bitvector_print (&b2); // disjoint? printf ("b1,b2 are disjoint %c (should be t)\n", bitvector_is_disjoint(&b1, &b2)?'t':'f'); printf ("union\n"); bitvector_union(&b1, &b2); // disjoint? printf ("b1,b2 are disjoint %c (should be f)\n", bitvector_is_disjoint(&b1, &b2)?'t':'f'); // print after union user_bitvector_print (&b1); user_bitvector_print (&b2); printf ("intersect\n"); bitvector_intersect(&b1, &b2); // disjoint? printf ("b1,b2 are disjoint %c (should be f)\n", bitvector_is_disjoint(&b1, &b2)?'t':'f'); // print after intersection user_bitvector_print (&b1); user_bitvector_print (&b2); printf ("invert b1\n"); bitvector_invert(&b1); // print after inversion user_bitvector_print (&b1); // disjoint? printf ("b1,b2 are disjoint %c (should be t)\n", bitvector_is_disjoint(&b1, &b2)?'t':'f'); bitvector_free (&b2); bitvector_free (&b1); matrix_t m1; matrix_t m2; dm_create (&m1, 10, 10); print_matrix (&m1); printf ("dm_set(4,4)\n"); dm_set (&m1, 4, 4); print_matrix (&m1); printf ("dm_unset(4,4)\n"); dm_unset (&m1, 4, 4); print_matrix (&m1); printf ("test shift permutation (3,4,5)(6,7)\n"); printf ("before\n"); dm_set (&m1, 3, 3); dm_set (&m1, 4, 4); dm_set (&m1, 5, 5); dm_set (&m1, 6, 6); dm_set (&m1, 7, 7); print_matrix (&m1); printf ("after\n"); // create permutation_group, apply permutation_group_t o1; dm_create_permutation_group (&o1, 2, NULL); dm_add_to_permutation_group (&o1, 3); dm_add_to_permutation_group (&o1, 4); dm_add_to_permutation_group (&o1, 5); dm_close_group (&o1); dm_add_to_permutation_group (&o1, 6); dm_add_to_permutation_group (&o1, 7); dm_permute_cols (&m1, &o1); print_matrix (&m1); dm_free_permutation_group (&o1); printf ("swap cols 6,7\n"); dm_swap_cols (&m1, 6, 7); print_matrix (&m1); printf ("swap rows 6,7\n"); dm_swap_rows (&m1, 6, 7); print_matrix (&m1); printf ("copy\n"); dm_create(&m2, dm_nrows(&m1), dm_ncols(&m1)); dm_copy (&m1, &m2); // TODO: needs some more work print_matrix (&m2); dm_sort_rows (&m1, &min_row_first); print_matrix (&m1); dm_sort_rows (&m1, &max_row_first); print_matrix (&m1); dm_print_perm (&(m1.row_perm)); printf ("to nub rows added & resorted\n"); dm_set (&m1, 7, 3); dm_set (&m1, 8, 4); dm_sort_rows (&m1, &max_row_first); print_matrix (&m1); printf ("flatten \n"); dm_flatten (&m1); print_matrix (&m1); dm_print_perm (&(m1.row_perm)); printf ("nub sorted\n"); //dm_nub_rows (&m1, &eq_rows, NULL); print_matrix (&m1); dm_print_perm (&(m1.row_perm)); /* * printf("again, now to test row order & nub idx\n"); dm_free(&m1); * dm_create(&m1, 10, 10); dm_set(&m1, 0,0); dm_set(&m1, 1,0); * dm_set(&m1, 2,3); dm_set(&m1, 3,3); print_matrix(&m1); * * printf("nub sorted\n"); * * dm_nub_rows(&m1); * * print_matrix(&m1); * * dm_print_perm(&(m1.row_perm)); */ printf ("optimize sorted\n"); dm_set (&m1, 0, 7); dm_set (&m1, 1, 6); dm_set (&m1, 3, 9); printf ("before\n"); print_matrix (&m1); dm_optimize (&m1); printf ("after\n"); print_matrix (&m1); printf ("resorted\n"); dm_sort_rows (&m1, &max_row_first); print_matrix (&m1); /* dm_nub_cols(&m1); dm_ungroup_rows(&m1); dm_ungroup_cols(&m1); print_matrix (&m1); */ // get bitvector from matrix text bitvector_create (&b1, 6); bitvector_create (&b2, 10); printf ("bitvector of row 0\n"); user_bitvector_print (&b2); printf ("bitvector of col 8\n"); user_bitvector_print (&b1); bitvector_free (&b2); bitvector_free (&b1); printf ("count test\n"); for (int i = 0; i < dm_nrows (&m1); i++) printf ("ones in row %d: %d\n", i, dm_ones_in_row (&m1, i)); for (int i = 0; i < dm_ncols (&m1); i++) printf ("ones in col %d: %d\n", i, dm_ones_in_col (&m1, i)); printf ("iterator test\n"); dm_row_iterator_t mx; dm_col_iterator_t my; for (int i = 0; i < dm_nrows (&m1); i++) { printf ("iterator row: %d\n", i); dm_create_row_iterator (&mx, &m1, i); int r; while ((r = dm_row_next (&mx)) != -1) printf (" next: %d\n", r); printf ("\n\n"); } for (int i = 0; i < dm_ncols (&m1); i++) { printf ("iterator col: %d\n", i); dm_create_col_iterator (&my, &m1, i); int r; while ((r = dm_col_next (&my)) != -1) printf (" next: %d\n", r); printf ("\n\n"); } printf ("projection test\n"); int s0[10]; int src[10]; int prj[2]; int tgt[10]; // initialize for (int i = 0; i < 10; i++) { s0[i] = -i; src[i] = i; } // do projection int prj_n = dm_project_vector (&m1, 0, src, prj); // print projection printf ("projection:"); for (int i = 0; i < prj_n; i++) { printf (" %d", prj[i]); } printf ("\n"); printf ("expansion test\n"); // do expansion int exp_n = dm_expand_vector (&m1, 0, s0, prj, tgt); (void)exp_n; // print expansion printf ("expansion:"); for (int i = 0; i < 10; i++) { printf (" %d", tgt[i]); } printf ("\n"); // subsumption printf ("subsumption test:\n"); dm_swap_rows (&m1, 0, 3); dm_swap_rows (&m1, 1, 2); dm_flatten (&m1); print_matrix (&m1); dm_subsume_rows (&m1, &eq_rows, NULL); printf ("after subsumption:\n"); print_matrix (&m1); printf ("\n"); printf ("after ungrouping:\n"); dm_ungroup_rows (&m1); print_matrix (&m1); printf ("\n"); printf ("column sort test:\n"); dm_flatten (&m1); printf ("max col first:\n"); dm_sort_cols (&m1, &max_col_first); print_matrix (&m1); printf ("min col first:\n"); dm_sort_cols (&m1, &min_col_first); print_matrix (&m1); printf ("nub columns test:\n"); dm_set (&m1, 0, 1); dm_set (&m1, 3, 1); dm_set (&m1, 3, 4); dm_set (&m1, 3, 5); dm_sort_cols (&m1, &max_col_first); // dm_flatten(&m1); printf ("max col first:\n"); print_matrix (&m1); //printf ("subsume columns:\n"); //dm_subsume_cols (&m1, &eq_cols, NULL); //dm_subsume_rows (&m1, &eq_rows, NULL); print_matrix (&m1); printf ("column permutation:\n"); dm_print_perm (&(m1.col_perm)); printf ("optimize columns:\n"); dm_optimize (&m1); print_matrix (&m1); //printf ("ungroup columns:\n"); //dm_ungroup_cols (&m1); //print_matrix (&m1); //printf ("all permutations:\n"); //dm_set (&m1, 0, 9); //dm_nub_cols(&m1, &eq_cols, NULL); //print_matrix (&m1); //dm_all_perm (&m1); dm_free (&m2); dm_free (&m1); return 0; }
/* ENDFS dfs_blue */ void endfs_blue (run_t *run, wctx_t *ctx) { HREassert (ecd, "CNDFS's correctness depends crucially on ECD"); alg_local_t *loc = ctx->local; cndfs_alg_local_t *cloc = (cndfs_alg_local_t *) ctx->local; transition_info_t ti = GB_NO_TRANSITION; uint32_t global_color; int accepting; cloc->successors = NONEC; endfs_handle_blue (ctx, ctx->initial, &ti, 0); ctx->counters->trans = 0; //reset trans count cloc->accepting_depth = 0; alg_global_t *sm = ctx->global; while ( !run_is_stopped(ctx->run) ) { raw_data_t state_data = dfs_stack_top (loc->stack); if (NULL != state_data) { state_info_deserialize (ctx->state, state_data); global_color = state_store_get_colors (ctx->state->ref); if (global_color < CBLUE && !on_stack_accepting_up(ctx, &accepting)) { if (global_color == CWHITE) update_color (ctx, ctx->state->ref, CCYAN, 0); if (all_red) bitvector_set (&loc->stackbits, cur(ctx,REDALL)); bitvector_unset (&loc->stackbits, cur(ctx,INVOL)); endfs_explore_state_blue (ctx); } else { if ( all_red && ctx->counters->level_cur != 0 && global_color != CRED ) bitvector_unset (&loc->stackbits, pred(ctx,REDALL)); dfs_stack_pop (loc->stack); } } else { //backtrack if (0 == dfs_stack_nframes(loc->stack)) break; dfs_stack_leave (loc->stack); ctx->counters->level_cur--; /* call red DFS for accepting states */ state_data = dfs_stack_top (loc->stack); state_info_deserialize (loc->seed, state_data); if (check_cndfs_proviso(ctx)) { reach_explore_all (ctx, loc->seed); continue; } accepting = pins_state_is_accepting(ctx->model, state_info_state(loc->seed)) != 0; /* Mark state GGREEN on backtrack */ update_color (ctx, loc->seed->ref, CBLUE, 1); if ( all_red && bitvector_is_set(&loc->stackbits, cur(ctx,REDALL)) ) { /* all successors are red */ //permute_trans (loc->permute, ctx->state, check, ctx); set_all_red2 (ctx, loc->seed); } else if ( accepting ) { sm->work = loc->seed->ref; endfs_red (ctx); if (Strat_ENDFS == loc->strat) endfs_handle_dangerous (ctx); else cndfs_handle_nonseed_accepting (ctx); sm->work = SIZE_MAX; } else if (all_red && ctx->counters->level_cur > 0 && state_store_get_colors (loc->seed->ref) != CRED) { /* unset the all-red flag (only for non-initial nodes) */ bitvector_unset (&loc->stackbits, pred(ctx,REDALL)); } accepting_down (ctx, loc->seed, accepting); dfs_stack_pop (loc->stack); } } HREassert (run_is_stopped(ctx->run) || fset_count(cloc->pink) == 0); // if the recursive strategy uses global bits (global pruning) // then do simple load balancing (only for the top-level strategy) if ( Strat_ENDFS == loc->strat && run == run->shared->top_level && (Strat_LTLG & sm->rec->local->strat) ) { endfs_lb (ctx); } if (global->exit_status == LTSMIN_EXIT_SUCCESS && ctx->id == 0) { Warning(info," "); Warning(info,"Empty product with LTL!"); Warning(info," "); } }
static void free_block(uint32_t blockno) { /* EXERCISE: Your code here */ bitvector_set(ospfs_block(OSPFS_FREEMAP_BLK), blockno); }
static void actual_main(void *arg) #endif { int argc = ((struct args_t*)arg)->argc; char **argv = ((struct args_t*)arg)->argv; /* initialize HRE */ HREinitBegin(argv[0]); HREaddOptions(options,"Perform a symbolic reachability analysis of <model>\n" "The optional output of this analysis is an ETF " "representation of the input\n\nOptions"); lts_lib_setup(); // add options for LTS library HREinitStart(&argc,&argv,1,2,files,"<model> [<etf>]"); /* initialize HRE on other workers */ init_hre(HREglobal()); /* check for unsupported options */ if (PINS_POR != PINS_POR_NONE) Abort("Partial-order reduction and symbolic model checking are not compatible."); if (inhibit_matrix != NULL && sat_strategy != NO_SAT) Abort("Maximal progress is incompatibale with saturation."); if (files[1] != NULL) { char *ext = strrchr(files[1], '.'); if (ext == NULL || ext == files[1]) { Abort("Output filename has no extension!"); } if (strcasecmp(ext, ".etf") != 0) { // not ETF if (!(vset_default_domain == VSET_Sylvan && strcasecmp(ext, ".bdd") == 0) && !(vset_default_domain == VSET_LDDmc && strcasecmp(ext, ".ldd") == 0)) { Abort("Only supported output formats are ETF, BDD (with --vset=sylvan) and LDD (with --vset=lddmc)"); } if (PINS_USE_GUARDS) { Abort("Exporting symbolic state space not comptabile with " "guard-splitting"); } } } #ifdef HAVE_SYLVAN if (!USE_PARALLELISM) { if (strategy == PAR_P) { strategy = BFS_P; Print(info, "Front-end not thread-safe; using --order=bfs-prev instead of --order=par-prev."); } else if (strategy == PAR) { strategy = BFS; Print(info, "Front-end not thread-safe; using --order=bfs instead of --order=par."); } } #endif /* turn off Lace for now to speed up while not using parallelism */ lace_suspend(); /* initialize the model and PINS wrappers */ init_model(files[0]); /* initialize action detection */ act_label = lts_type_find_edge_label_prefix (ltstype, LTSMIN_EDGE_TYPE_ACTION_PREFIX); if (act_label != -1) action_typeno = lts_type_get_edge_label_typeno(ltstype, act_label); if (act_detect != NULL) init_action_detection(); bitvector_create(&state_label_used, sLbls); if (inv_detect != NULL) init_invariant_detection(); else if (PINS_USE_GUARDS) { for (int i = 0; i < nGuards; i++) { bitvector_set(&state_label_used, i); } } init_maxsum(ltstype); /* turn on Lace again (for Sylvan) */ if (vset_default_domain==VSET_Sylvan || vset_default_domain==VSET_LDDmc) { lace_resume(); } if (next_union) vset_next_fn = vset_next_union_src; init_domain(VSET_IMPL_AUTOSELECT); vset_t initial = vset_create(domain, -1, NULL); int *src = RTmalloc (sizeof(int[N])); GBgetInitialState(model, src); vset_add(initial, src); Print(infoShort, "got initial state"); /* if writing .dot files, open directory first */ if (dot_dir != NULL) { DIR* dir = opendir(dot_dir); if (dir) { closedir(dir); } else if (ENOENT == errno) { Abort("Option 'dot-dir': directory '%s' does not exist", dot_dir); } else { Abort("Option 'dot-dir': failed opening directory '%s'", dot_dir); } } if (vset_dir != NULL) { DIR *dir = opendir(vset_dir); if (dir) { closedir(dir); } else if (errno == ENOENT) { Abort("Option 'save-levels': directory '%s' does not exist", vset_dir); } else { Abort("Option 'save-levels': failed opening directory '%s'", vset_dir); } } init_mu_calculus(); /* determine if we need to generate a symbolic parity game */ #ifdef LTSMIN_PBES bool spg = true; #else bool spg = GBhaveMucalc() ? true : false; #endif /* if spg, then initialize labeling stuff before reachability */ if (spg) { Print(infoShort, "Generating a Symbolic Parity Game (SPG)."); init_spg(model); } /* create timer */ reach_timer = RTcreateTimer(); /* fix level 0 */ visited = vset_create(domain, -1, NULL); vset_copy(visited, initial); /* check the invariants at level 0 */ check_invariants(visited, 0); /* run reachability */ run_reachability(visited, files[1]); /* report states */ final_stat_reporting(visited); /* save LTS */ if (files[1] != NULL) { char *ext = strrchr(files[1], '.'); if (strcasecmp(ext, ".etf") == 0) { do_output(files[1], visited); } else { // if not .etf, then the filename ends with .bdd or .ldd, symbolic LTS do_dd_output (initial, visited, files[1]); } } compute_maxsum(visited, domain); CHECK_MU(visited, src); if (max_mu_count > 0) { Print(info, "Mu-calculus peak nodes: %ld", max_mu_count); } /* optionally print counts of all group_next and group_explored sets */ final_final_stats_reporting (); if (spg) { // converting the LTS to a symbolic parity game, save and solve. lts_to_pg_solve (visited, src); } #ifdef HAVE_SYLVAN /* in case other Lace threads were still suspended... */ if (vset_default_domain!=VSET_Sylvan && vset_default_domain!=VSET_LDDmc) { lace_resume(); } else if (SYLVAN_STATS) { sylvan_stats_report(stderr); } #endif RTfree (src); GBExit(model); }