void swap_remove (uint32_t swap_index) { ASSERT (swap_index < total_swap_size); lock_acquire (&swap_lock); ASSERT (bitmap_test (swap_bitmap, swap_index)); bitmap_reset (swap_bitmap, swap_index); lock_release (&swap_lock); }
size_t block_store_release(block_store_t *const bs, const size_t block_id) { if (bs && bs->fbm && BLOCKID_VALID(block_id)) { // we could clear the dirty bit, since the info is no longer in use but... // We'll keep it. Could be useful. Doesn't really hurt anything. // Keeps it more true to a standard block device. // You could also use this function to format the specified block for security reasons bitmap_reset(bs->fbm, block_id); block_store_errno = BS_OK; return block_id; } block_store_errno = BS_PARAM; return 0; }
void wavefront_bitmap_initialize( struct bitmap *b ) { int i, j; bitmap_reset(b,WAVEFRONT_TASK_STATE_NOTREADY); for(i=0;i<=xsize;i++) { bitmap_set(b,i,0,WAVEFRONT_TASK_STATE_COMPLETE); } for(j=0;j<=ysize;j++) { bitmap_set(b,0,j,WAVEFRONT_TASK_STATE_COMPLETE); } }
void swap_read (void *dest, uint32_t swap_index) { uint32_t i; ASSERT (swap_index < total_swap_size); lock_acquire (&swap_lock); ASSERT (bitmap_test (swap_bitmap, swap_index)); bitmap_reset (swap_bitmap, swap_index); for (i = 0u; i < blocks_per_page; i++) { block_read (swap_block, swap_index * blocks_per_page + i, (char *)dest + i * BLOCK_SECTOR_SIZE); } lock_release (&swap_lock); }
void wavefront_task_initialize( struct bitmap *b, struct list * list ) { int i, j; bitmap_reset(b,WAVEFRONT_TASK_STATE_NOTREADY); for(i=0;i<=xsize;i++) { bitmap_set(b,i,0,WAVEFRONT_TASK_STATE_COMPLETE); } for(j=0;j<=ysize;j++) { bitmap_set(b,0,j,WAVEFRONT_TASK_STATE_COMPLETE); } list_push_head(list,wavefront_task_create(xstart,ystart,block_size,block_size)); }
void load_swapped_page_into_frame(struct page_info* p, void* frame) { lock_acquire(&swap_lock); int index = p->swap_info.swap_index; bitmap_reset(swapmap, index); // Read the 4KB page from disk to the passed-in frame // We're going to need to read out eight sectors, one at a time block_sector_t sector_index = index * SECTORS_PER_PAGE; int i; for (i = 0; i < SECTORS_PER_PAGE; i++) { block_sector_t source_sector = sector_index + i; void* target_buf = (uint8_t *)frame + (i * BLOCK_SECTOR_SIZE); block_read(swap_block, source_sector, target_buf); } lock_release(&swap_lock); }
void delete_swapped_page(struct page_info* p) { lock_acquire(&swap_lock); int index = p->swap_info.swap_index; bitmap_reset(swapmap, index); lock_release(&swap_lock); }
void tm_thread_release_stacks(struct thread *thr) { mutex_acquire(&thr->process->stacks_lock); bitmap_reset(thr->process->stack_bitmap, thr->stack_num); mutex_release(&thr->process->stacks_lock); }
void bitmap_writer_build(struct packing_data *to_pack) { static const double REUSE_BITMAP_THRESHOLD = 0.2; int i, reuse_after, need_reset; struct bitmap *base = bitmap_new(); struct rev_info revs; writer.bitmaps = kh_init_sha1(); writer.to_pack = to_pack; if (writer.show_progress) writer.progress = start_progress("Building bitmaps", writer.selected_nr); init_revisions(&revs, NULL); revs.tag_objects = 1; revs.tree_objects = 1; revs.blob_objects = 1; revs.no_walk = 0; revs.include_check = should_include; reset_revision_walk(); reuse_after = writer.selected_nr * REUSE_BITMAP_THRESHOLD; need_reset = 0; for (i = writer.selected_nr - 1; i >= 0; --i) { struct bitmapped_commit *stored; struct object *object; khiter_t hash_pos; int hash_ret; stored = &writer.selected[i]; object = (struct object *)stored->commit; if (stored->bitmap == NULL) { if (i < writer.selected_nr - 1 && (need_reset || !in_merge_bases(writer.selected[i + 1].commit, stored->commit))) { bitmap_reset(base); reset_all_seen(); } add_pending_object(&revs, object, ""); revs.include_check_data = base; if (prepare_revision_walk(&revs)) die("revision walk setup failed"); traverse_commit_list(&revs, show_commit, show_object, base); revs.pending.nr = 0; revs.pending.alloc = 0; revs.pending.objects = NULL; stored->bitmap = bitmap_to_ewah(base); need_reset = 0; } else need_reset = 1; if (i >= reuse_after) stored->flags |= BITMAP_FLAG_REUSE; hash_pos = kh_put_sha1(writer.bitmaps, object->sha1, &hash_ret); if (hash_ret == 0) die("Duplicate entry when writing index: %s", sha1_to_hex(object->sha1)); kh_value(writer.bitmaps, hash_pos) = stored; display_progress(writer.progress, writer.selected_nr - i); } bitmap_free(base); stop_progress(&writer.progress); compute_xor_offsets(); }
static void free_swap_slot (size_t swap_sector_idx) { lock_acquire (&swap_lock); bitmap_reset (used_map, swap_sector_idx / SECTORS_PER_SWAP); lock_release (&swap_lock); }