Пример #1
0
/* Initializes all persistent caches.
 * Needs to be called only once at startup.
 */
void
persistent_cache_init()
{
  init_cache(&reading_cache);
  init_cache(&breakin_cache);
  init_cache(&connection_cache);
  init_cache(&owl_cache);
}
Пример #2
0
int main(int argc, char *argv[])
{
    int listenfd;
    socklen_t clientlen;
    struct sockaddr_storage clientaddr;
    pthread_t tid;

    init_cache();
    signal(SIGPIPE, SIG_IGN);

    /* Check command line args */
    if (argc != 2) {
	fprintf(stderr, "usage: %s <port>\n", argv[0]);
	exit(1);
    }

    listenfd = Open_listenfd(argv[1]);
    while (1) {
	int *connfdp = Malloc(sizeof(int));
	clientlen = sizeof(clientaddr);
	*connfdp = Accept(listenfd, (SA *)&clientaddr, &clientlen);
	Pthread_create(&tid, NULL, doit_thread, connfdp);
    }
    delete_cache();
    return 0;
}
Пример #3
0
int main (int argc, char *argv []) {
    int listen_fd, port;
    int client_fd;
    socklen_t socket_length;
    struct sockaddr_in client_socket;

    pthread_mutex_init(&mutex_lock, NULL);
    init_cache();
    Signal (SIGPIPE, SIG_IGN);
    if (argc != 2) {
	    fprintf(stderr, "usage: %s <port>\n", argv[0]);
	    exit(0);
    }

    port = atoi(argv[1]);
    listen_fd = Open_listenfd(port);
    socket_length = sizeof(client_socket);

    while (1) {
        client_fd = Accept(listen_fd, (SA*)&client_socket, &socket_length);   
        scheduler(client_fd);
    }
    pthread_mutex_destroy(&mutex_lock);
    clean_cache();
}
Пример #4
0
/*********************************************************************
* init_main - Main entry point for initialisation code               *
**********************************************************************/
void init_main(void)
{
  init_clock_config();

  /* Disable interrupts, watchdog timer, cache */
  disable_interrupts();
  disable_watchdog_timer();
  disable_cache();

  /* Initialise individual modules */
  init_cache();
  init_crossbar();
  init_chip_selects();
  init_eport();
  init_flexcan();
  init_dma_timers();
  init_interrupt_timers();
  init_real_time_clock();
  init_watchdog_timers();
  init_edma();
  init_pin_assignments();

  /* Initialise SDRAM controller (must be done after pin assignments) */
  init_sdram_controller();

  /* Initialise interrupt controller */
  init_interrupt_controller();
}
Пример #5
0
int main(int argc, char *argv[]){
    int s, E, b;
	char *trace = (char*) malloc(50 * sizeof(char));
	cache sim_cache;
	get_opts(argc,argv, &s, &E, &b, trace);
	init_cache(&sim_cache, s, E, b);

	FILE *p_t = fopen(trace, "r");
	if(! p_t){
		fprintf(stderr, "error when open trace file %s\n", trace);
		return -1;
	}

	int hit, miss, evict;
	hit = miss = evict = 0;
	
	char *buffer = (char*) malloc(50 * sizeof(char));
	while(fgets(buffer, 50, p_t) != NULL){
		if(buffer[0] == ' '){
			parse_buffer(&sim_cache, buffer, s, E, b, &hit, &miss, &evict);
		}
	}

	printSummary(hit, miss, evict);
	return 0;
}
Пример #6
0
status check_direct(int test[], char* hit_miss[] , int s ,int l, int test_num ){
  int i, j ;
  int numlines ;
  unsigned int new_tag, index ;
  queue Q ;

  numlines= s / l ;
  line cache[MAXLINES] ;
  // initialize the cache and the queue
  // the queue will store the index of the cache line
  // which has its valid field changed from 0 to 1
  init_cache ( cache, numlines ) ;
  init_queue ( &Q ) ;

  for ( i = 0 ; i < test_num; i++ ){
    if( cache_full( cache, numlines ) == TRUE )
      evict_cache( cache , &Q ) ;
    get_tag_index ( &new_tag, &index, test[i], l, numlines ) ;

    if( cache[index].valid == 1 &&  cache[index].tag == new_tag )
      hit_miss[i] = "HIT" ;
    else{
      hit_miss[i] = "MISS" ;
      cache[index].tag = new_tag ;
      if ( cache[index].valid == 0 ){
        push_int( &Q, index ) ;
      }
      cache[index].valid = 1 ;
    }
  }
  return OK ;
}
Пример #7
0
/**
 * Turn LRU deferred writes on or off.
 * @return -1 on error with errno set, 0 if OK.
 */
int
setwdelay(DBM *db, bool on)
{
	struct lru_cache *cache = db->cache;

	if (NULL == cache)
		return init_cache(db, LRU_PAGES, on);

	sdbm_lru_check(cache);

	if (on == cache->write_deferred)
		return 0;

	/*
	 * Value is inverted.
	 */

	if (cache->write_deferred) {
		flush_dirtypag(db);
		cache->write_deferred = FALSE;
	} else {
		cache->write_deferred = TRUE;
	}

	return 0;
}
Пример #8
0
/*
 * Prepare utility plans and plan cache.
 */
static void init_module(void)
{
	static int callback_init = 0;

	/* do full reset if requested */
	if (tbl_cache_invalid) {
		if (tbl_cache_map)
			hash_destroy(tbl_cache_map);
		if (tbl_cache_ctx)
			MemoryContextDelete(tbl_cache_ctx);
		tbl_cache_map = NULL;
		tbl_cache_ctx = NULL;
		tbl_cache_invalid = false;
	}

	/* re-initialize cache */
	if (tbl_cache_ctx)
		return;
	init_cache();

	/*
	 * Rest is done only once.
	 */

	if (!pkey_plan)
		init_pkey_plan();

	if (!callback_init) {
		CacheRegisterRelcacheCallback(relcache_reset_cb, (Datum)0);
		callback_init = 1;
	}
}
Пример #9
0
static void init_terrain(int i)
{
    if (terrain[i].state == 0)
    {
        GLushort *indices;

        indices    = init_indices(terrain[i].n);
        terrain[i].ibo = init_ibo(terrain[i].n, indices);
        free(indices);

        terrain[i].scratch = init_scratch(terrain[i].n);
        terrain[i].cache   = init_cache  (terrain[i].n, terrain[i].m);

        terrain[i].tail    = terrain[i].m - 1;
        terrain[i].head    = 0;
        terrain[i].state   = 1;

        terrain[i].tex[0][0] = init_texture("mars2.dxt", 4096, 4096);
        terrain[i].tex[1][0] = init_texture("mars3.dxt", 4096, 4096);
        terrain[i].tex[2][0] = init_texture("mars0.dxt", 4096, 4096);
        terrain[i].tex[3][0] = init_texture("mars1.dxt", 4096, 4096);
        terrain[i].tex[0][1] = init_texture("mars6.dxt", 4096, 4096);
        terrain[i].tex[1][1] = init_texture("mars7.dxt", 4096, 4096);
        terrain[i].tex[2][1] = init_texture("mars4.dxt", 4096, 4096);
        terrain[i].tex[3][1] = init_texture("mars5.dxt", 4096, 4096);

		glBindTexture   (GL_TEXTURE_2D,              0);
        glBindBufferARB(GL_ARRAY_BUFFER_ARB,         0);
        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);

    }
}
Пример #10
0
int main(int argc, char* argv[])
{
	signal(SIGINT,  Exit);
  	signal(SIGTERM, Exit);

	uint32_t i,j, err_flag;

	err_flag = 0;

	init_cache();

	for(i = 0; i < 2048; i++)
	{
		write_mem(i,i);
	}

	for(i = 0; i < 2048; i++)
	{
		j = read_mem(i);
		if(j != i)
		{
			fprintf(stderr,"Error: expected %d, read %d\n", i,j);
			err_flag = 1;
		}
	}
			
       fprintf(stderr,"Test finished, %s\n", (err_flag ? "with errors" : "successfully"));

	return(0);
}
Пример #11
0
static int bee_dep_rebuild(int argc, char *argv[])
{
    int c, help;
    struct hash *graph;
    struct option long_options[] = {
        {"help", 0, &help, 1},
        {0, 0, 0, 0}
    };

    help = 0;

    while ((c = getopt_long(argc, argv, "", long_options, NULL)) != -1) {
        switch (c) {
            case '?':
                usage_update();
                return 1;
        }
    }

    if (help) {
        usage_rebuild();
        return 0;
    }

    if (argc > 1) {
        fprintf(stderr, "bee-dep: too many arguments\n");
        return 1;
    }

    graph = init_cache();
    hash_free(graph);

    return 0;
}
Пример #12
0
/**
 * Initialize the LRU page cache with default values.
 */
void lru_init(DBM *db)
{
	g_assert(NULL == db->cache);
	g_assert(-1 == db->pagbno);		/* We must be called before first access */

	if (-1 == init_cache(db, LRU_PAGES, FALSE))
		s_error("out of virtual memory");
}
Пример #13
0
void cachesim_init(int argc, char** argv) {
  int levels = argc/3, i;
  caches = malloc(sizeof(*caches)*levels);
  
  for (i = 0; i < levels; i++) {
    init_cache(&caches[i], (i==levels-1)?NULL:&caches[i+1],
               atol(argv[3*i]), atol(argv[3*i + 1]), atol(argv[3*i + 2]));
  }
}
Пример #14
0
void Init_Caches(void)
{
    CDS *cds = CDS_root;
    while (cds != NULL)
        {
            init_cache(cds);
            cds = cds->next;
        }
}
Пример #15
0
int main()
{
	int size;

	mydisk_init("diskfile", MAX_BLOCKS, 0);
	init_cache(CACHED_BLOCKS);
	
	/* Test case 1: read/write block */
	size = BLOCK_SIZE;
	memset(buffer, 0, size);
	strcpy(buffer, "hello world\n");
	mydisk_write_block(0, buffer);
	memset(buffer2, 0, size);
	mydisk_read_block(0, buffer2);
	check_test(memcmp(buffer2, "hello world\n", 13));

	/* Test case 2: basic read/write */
	memset(buffer, 0, size);
	mydisk_read(0, 13, buffer);
	check_test(memcmp(buffer, "hello world\n", 13));

	/* Test case 3: read in the middle */
	memset(buffer, 0, BLOCK_SIZE);
	mydisk_read(8, 5, buffer);
	check_test(memcmp(buffer, "rld\n", 5));

	/* Test case 4: read/write across blocks */
	size = BLOCK_SIZE;
	rand_str(buffer, size);
	mydisk_write(144, size, buffer);
	memset(buffer2, 0, size);
	mydisk_read(144, size, buffer2);
	check_test(memcmp(buffer, buffer2, size));

	/* Test case 5: large read/write */
	size = BLOCK_SIZE * (MAX_BLOCKS - 1);
	rand_str(buffer, size);
	mydisk_write(276, size, buffer);
	mydisk_read(276, size, buffer2);
	check_test(memcmp(buffer, buffer2, size));

	/* Test case 6~9: read/write exception */
	check_test(!mydisk_read(-1, 0, buffer));
	check_test(!mydisk_read(0, -10, buffer));
	check_test(!mydisk_read(100, BLOCK_SIZE * MAX_BLOCKS, buffer));
	check_test(mydisk_write(0, 0, buffer));

	check_test(stress_test());
	check_test(stress_test2());

	close_cache();
	mydisk_close();
	return 0;
}
Пример #16
0
int main()
{
	cache_head_t cache;
	init_cache(&cache, 8);
	long long *data = cache_malloc(&cache);
	*data = 111111111;
	cache_free(&cache, data);
	data = cache_malloc(&cache);
	cache_free(&cache, data);
	return 0;
}
Пример #17
0
static void test1(void) {
  printf("***************************\n"
	 "*        TEST 1           *\n"
	 "***************************\n");

  init_cache(&cache);
  printf("\n--- Initial cache ---\n");
  print_all_cache(stdout, &cache);

  test_elem(A, 1, 1);
  test_elem(A, 1, 1);

  printf("\n--- After addition ---\n");
  print_all_cache(stdout, &cache);

  test_elem(B, 2, 2);
  test_elem(B, 2, 2);

  printf("\n--- After more addition ---\n");
  print_all_cache(stdout, &cache);

  cache_push(&cache);
  cache_push(&cache);
  printf("\n--- Push: level 2 ---\n");
  print_all_cache(stdout, &cache);

  test_elem(A, 0, 1);
  test_elem(A, 0, 1);

  test_elem(A, 1, 0);
  test_elem(A, 1, 0);

  printf("\n--- Content ---\n");
  print_all_cache(stdout, &cache);

  cache_push(&cache);
  printf("\n--- Push: level 3 ---\n");
  print_all_cache(stdout, &cache);

  cache_pop(&cache);
  printf("\n--- Pop: level 2 ---\n");
  print_all_cache(stdout, &cache);

  cache_pop(&cache);
  printf("\n--- Pop: level 1 ---\n");
  print_all_cache(stdout, &cache);

  cache_pop(&cache);
  printf("\n--- Pop: level 0 ---\n");
  print_all_cache(stdout, &cache);

  delete_cache(&cache);
}
Пример #18
0
void bt_initialise_slab() {

	BT_u32 i = BT_CACHE_GENERIC_MIN;
	while(i <= BT_CACHE_GENERIC_MAX) {
		BT_CACHE *pCache = BT_GetSuitableCache(i);
		if(!pCache) {
			break;
		}
		init_cache(pCache, i);
		i = i << 1;
	}
}
Пример #19
0
/* This is the C kernel entry point */
void kmain(struct multiboot *mboot_header, addr_t initial_stack)
{
	/* Store passed values, and initiate some early things
	 * We want serial log output as early as possible */
	kernel_state_flags=0;
	mtboot = mboot_header;
	i_stack = initial_stack;
	parse_kernel_elf(mboot_header, &kernel_elf);
#if CONFIG_MODULES
	init_kernel_symbols();
#endif
	init_serial();
	console_init_stage1();
	load_tables();
	puts("~ SeaOS Version ");	
	char ver[32];
	get_kernel_version(ver);
	puts(ver);
	puts(" Booting Up ~\n\r");
#if CONFIG_MODULES
	init_module_system();
#endif
	init_syscalls();
	load_initrd(mtboot);
	install_timer(1000);
	pm_init(placement, mtboot);
	init_main_cpu_1();

	/* Now get the management stuff going */
	printk(1, "[kernel]: Starting system management\n");
	init_memory(mtboot);
	init_main_cpu_2();
	console_init_stage2();
	parse_kernel_cmd((char *)(addr_t)mtboot->cmdline);
	init_multitasking();
	init_cache();
	init_dm();
	init_vfs();
	/* Load the rest... */
	process_initrd();
	init_kern_task();
	get_timed(&kernel_start_time);
	printk(KERN_MILE, "[kernel]: Kernel is setup (%2.2d:%2.2d:%2.2d, %s, kv=%d, ts=%d bytes: ok)\n", 
	       kernel_start_time.tm_hour, kernel_start_time.tm_min, 
	       kernel_start_time.tm_sec, kernel_name, KVERSION, sizeof(task_t));
	assert(!set_int(1));
	if(!fork())
		init();
	sys_setsid();
	enter_system(255);
	kernel_idle_task();
}
Пример #20
0
int init_cache_f_r(void)
{
#if CONFIG_IS_ENABLED(X86_32BIT_INIT) && !defined(CONFIG_HAVE_FSP)
	int ret;

	ret = mtrr_commit(false);
	/* If MTRR MSR is not implemented by the processor, just ignore it */
	if (ret && ret != -ENOSYS)
		return ret;
#endif
	/* Initialise the CPU cache(s) */
	return init_cache();
}
Пример #21
0
void set_defaults(void) {

    char param_value[LINE_MAX + 1];
    get_param("INSTR_SLICE", param_value);
    instr_slice = atoi(param_value);

    int heads, tracks, sectors;
    char command[1000];
    get_param("NUM_HEADS", param_value);
    heads = atoi(param_value);
    get_param("NUM_TRACKS", param_value);
    tracks = atoi(param_value);
    get_param("NUM_SECTORS", param_value);
    sectors = atoi(param_value);
    FILE* check = fopen("Sim_disk", "r");
    if(check != NULL) {
        disk_file_pointer = fopen("Sim_disk", "rb+");
        read_super_block();
        init_cache();
        fclose(check);
    }
    else {
        total_blocks_virtual_mem = (heads * tracks * sectors) / 8;
        blocks_in_track = total_blocks_virtual_mem / tracks;
        prev_track = 0;
        disk_block_data = (int *) malloc(total_blocks_virtual_mem * sizeof(int));
        int i = 0;
        for (i = 0; i < total_blocks_virtual_mem; i++)
            disk_block_data[i] = -1;
        sprintf(command,
                "(dd if=/dev/zero of=Sim_disk bs=%dx%dx%db count=1) 2> /dev/zero",
                heads, tracks, sectors);
        system(command);
        disk_file_pointer = fopen("Sim_disk", "rb+");
        init_super_block();
        init_cache();
    }
}
Пример #22
0
/* looks for a cached size request for this for_size. If not
 * found, returns the oldest entry so it can be overwritten
 *
 * Note that this caching code was originally derived from
 * the Clutter toolkit but has evolved for other GTK+ requirements.
 */
static gboolean
get_cached_size (GtkWidget         *widget,
		 GtkSizeGroupMode   orientation,
		 gint               for_size,
		 CachedSize       **result)
{
  SizeRequestCache  *cache;
  SizeRequest      **cached_sizes;
  guint              i, n_sizes;

  cache = init_cache (widget);

  if (for_size < 0)
    {
      if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
	{
	  *result = &cache->cached_width;
	  return cache->cached_base_width;
	}
      else
	{
	  *result = &cache->cached_height;
	  return cache->cached_base_height;
	}
    }

  if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
    {
      cached_sizes = cache->widths;
      n_sizes      = cache->cached_widths;
    }
  else
    {
      cached_sizes = cache->heights;
      n_sizes      = cache->cached_heights;
    }

  /* Search for an already cached size */
  for (i = 0; i < n_sizes; i++)
    {
      if (cached_sizes[i]->lower_for_size <= for_size &&
	  cached_sizes[i]->upper_for_size >= for_size)
	{
	  *result = &cached_sizes[i]->cached_size;
	  return TRUE;
	}
    }

  return FALSE;
}
QcOfflineCacheDatabase::QcOfflineCacheDatabase(QString sqlite_path)
{
  bool create = !QFile(sqlite_path).exists();

  m_database = QSqlDatabase::addDatabase(QStringLiteral("QSQLITE"), sqlite_path);
  m_database.setDatabaseName(sqlite_path);
  if (!m_database.open())
    qWarning() << m_database.lastError().text();

  if (create)
    create_tables();
  else
    init_cache();
}
Пример #24
0
int main(int argc, char *argv[])
{
	int i;

	init_cache();

	i = argc;
	while (i>1)
		printf("%d\n", collatz(atoi(argv[--i])));

	free_cache();

	return 0;
}
Пример #25
0
struct hash *get_cache(void)
{
    struct hash *graph;
    struct stat st;

    if (stat(cache_filename(), &st) == -1)
        graph = init_cache();
    else
        graph = load_cache(cache_filename());

    if (!graph)
        exit(EXIT_FAILURE);

    return graph;
}
Пример #26
0
int main(int argc, char **argv)
{
	int listenfd;
	char hostname[MAXLINE], port[MAXLINE];

	/* Check command line args */
	if (argc != 2) {
		fprintf(stderr, "usage: %s <port>\n", argv[0]);
		exit(1);
	}

	listenfd = Open_listenfd(argv[1]);
	Sem_init(&list_lock, 0, 1);
	// init cache's head node
	head = (struct cache_block*) malloc(sizeof(struct cache_block));
	init_cache(head);

	// block sigpipe
	Signal(SIGPIPE, SIG_IGN);

	while (1) {

		pthread_t tid;
		// allocate space for a thread arg
		thread_args* args_ptr = (thread_args*) malloc(sizeof(thread_args));
		if (!args_ptr) {
			printf("malloc failure\n");
			continue;
		}
		socklen_t clientlen = sizeof(struct sockaddr_storage);
		printf("Preparing to connect with clients...\n");

		args_ptr->fd = Accept(listenfd, 
			(SA *)&args_ptr->socket_addr, &clientlen);
		
		if (getnameinfo((SA *) &args_ptr->socket_addr, 
			clientlen, hostname, MAXLINE, port, MAXLINE, 0) != 0) {
			printf("getnameinfo failure\n");
			continue;
		}
		printf("Accepted connection from (%s, %s)\n", hostname, port);
		if (pthread_create(&tid, NULL, thread, args_ptr) != 0) {
			printf("pthread_create error\n");
			continue;
		}
	}

}
Пример #27
0
int main() {
    cache_t cache;
    memory_t memory;
    unsigned char *p_raw;

    int i, count;

    p_raw = malloc(TESTMEM_SIZE);
    bzero(p_raw, TESTMEM_SIZE);

    init_memory(&memory, TESTMEM_SIZE);
    init_cache(&cache, /* block_size */ 64, /* num_sets */ 16,
        /* lines_per_set */ 64, (membase_t *) &memory);

    printf("Running test.\n");
    
    for (i = 0; i < NUM_WRITES; i++) {
        addr_t addr = rand() % TESTMEM_SIZE;
        unsigned char value = rand() % 256;

#if DEBUG_TESTMEM
        printf("Writing value %u to address %u\n", value, addr);
#endif

        p_raw[addr] = value;
        write_byte((membase_t *) &cache, addr, value);
    }

    flush_cache(&cache);

    count = 0;
    for (i = 0; i < TESTMEM_SIZE; i++) {
        if (p_raw[i] != memory.mem[i]) {
            count++;
            printf("Values at index %d don't match:  raw[i] = %u, mem[i] = %u\n",
                i, p_raw[i], memory.mem[i]);
        }
    }

    if (count == 0)
        printf("Memories are identical.\n");

    cache.free((membase_t *) &cache);
    memory.free((membase_t *) &memory);

    return 0;
}
Пример #28
0
int main(int argc, char **argv)
{
    pthread_t tid;
    //printf("%s%s%s", user_agent_hdr, accept_hdr, accept_encoding_hdr);
    int listenfd, *connfdp, port=0, clientlen;
    struct sockaddr_in clientaddr;

    /* Check command line args */
    if (argc != 2) {
        fprintf(stderr, "usage: %s <port>\n", argv[0]);
        exit(1);
    }
	
    Signal(SIGPIPE,SIG_IGN);

    port = atoi(argv[1]);

    if (port==0){
        fprintf(stderr,"wrong port number.\n");
        exit(1);
    }
    
    // cache
    cache_head=init_cache();

    listenfd = Open_listenfd(port);

    if (listenfd == -1){
        fprintf(stderr,"Error:open listenfd\n");
        exit(1);
    }

    clientlen = sizeof(clientaddr);
    
    while (1) {

        printf("main wait\n");
        connfdp=Malloc(sizeof(int));
        *connfdp = Accept(listenfd, (SA *) &clientaddr, (socklen_t *) &clientlen);
        Pthread_create(&tid,NULL,thread,connfdp);

        printf("end main while\n");
    }

    return 0;
}
Пример #29
0
int
cmsg(const char *msgid)
{
	Item *itemp;
	int len;

	if (msgs_cache == (Cache *) NULL)
		if (init_cache(&msgs_cache, HASHSIZE, BSZ,
		    (int (*)())NULL, (int (*)())NULL) == -1) {
			(void) fprintf(stderr,
			    gettext("cmsg(): init_cache() failed.\n"));
			exit(1);
		}

	len = strlen(msgid) + 1;

	if ((itemp = lookup_cache(msgs_cache, (void *) msgid, len)) ==
	    Null_Item) {
		if ((itemp = (Item *) malloc(sizeof (*itemp))) == Null_Item) {
			(void) fprintf(stderr,
			    gettext("cmsg(): itemp=malloc(%d)\n"),
			    sizeof (*itemp));
			exit(1);
		}

		if ((itemp->key = (char *) malloc(len)) == NULL) {
			(void) fprintf(stderr,
			    gettext("cmsg(): itemp->key=malloc(%d)\n"),
			    len);
			exit(1);
		}
		(void) memmove(itemp->key, msgid, len);
		itemp->keyl = len;

		itemp->data = NULL;
		itemp->datal = 0;

		if (add_cache(msgs_cache, itemp) == -1)
			(void) fprintf(stderr,
			    gettext("cmsg(): add_cache() failed.\n"));

		return (0);
	} else {
		return (1);
	}
}
Пример #30
0
 Pager::Pager(const std::string & name, FileMode mode, int size_limit)
     :file(nullptr), index(size_limit), max_size(size_limit), size(0) //Note: load factor of the hashmap is 1
 {
     if (mode & OPEN){
         file = std::fopen(name.c_str(), "r+b");
         _status = OPEN;
     }
     if (!file && (mode & NEW)){
         file = std::fopen(name.c_str(), "w+b");
         _status = NEW;
     }
     if (file){
         init_cache();
     }else{
         throw std::runtime_error("cannot open data file");
     }
 }