Esempio n. 1
0
long long int storage__get_number_of_blocks(const struct storage__file* c) {
    off_t prevpos = ftello(c->index_file);
    
    long long int number_of_blocks = get_number_of_blocks(c->index_file, c->block_group_size);
    
    fseeko(c->index_file, prevpos, SEEK_SET);
    
    return number_of_blocks;
}
Esempio n. 2
0
void generate_line(struct passed_args *args, struct cache_line *ya_line, long tag) {
/*
    Function to generate and initialize a line of cache set
*/
    char block_bits_num = get_block_bits_num(args);
    int number_of_blocks = get_number_of_blocks(block_bits_num);
    long *bytes = calloc(number_of_blocks, sizeof(long));
    ya_line->bytes = bytes;
    ya_line->valid_bit = 0;
    ya_line->tag = tag;
    ya_line->age = 0;
}
Esempio n. 3
0
long long int storage__get_number_of_blocks2(const char* dirname, const char* basename) {
    int block_size, block_group_size;
    
    
    char namebuf[4096];
    snprintf(namebuf, 4096, "%s/%s.dsc", dirname, basename);
    FILE* dsc_file = fopen(namebuf, "rb");
    if(dsc_file==NULL)return -1;
    
    int ret = fscanf(dsc_file,"%d%d\n", &block_size, &block_group_size);
    assert(ret==2);
    
    fclose(dsc_file);
    snprintf(namebuf, 4096, "%s/%s.idx", dirname, basename);
    FILE* index_file = fopen(namebuf, "rb");
    if(index_file==NULL)return -1;
    

    long long int number_of_blocks = get_number_of_blocks(index_file, block_group_size);
    
    fclose(index_file);
    
    return number_of_blocks;
}