Beispiel #1
0
int mmgr_get_first_range_free(int size){
  uint32_t i,j,count;
  uint64_t bit;
  for(i=0; i< (get_total_blocks() / 64); i++){
      if(mmgr_memory_map[i] != 0xFFFFFFFFFFFFFFFF){
          for(j=0; j<64; j++){
              bit = 1<<j;
              if(!(mmgr_memory_map[i] & bit)){
                  uint32_t temp_bit = i*64; // Go to that corresponding frame
                  uint32_t free = 0;
                  temp_bit += j;
                  for(count=0; count<size; count++){
                      if( !(mmgr_is_block_free(temp_bit + count)) )
                          free++;
                      else{
                          j=j+(count);
                          break; // No use of being in this loop anymore
                      }
                      if(free == size)
                          return ((i*64)+j);  // Found the required range. Return it
                  }
              }
          }
      }
  }
  return -1;
}
Beispiel #2
0
int		list_column_dir(char *dir, t_opt *t)
{
  DIR		*d;
  struct dirent	*e;
  struct stat	s;
  char		*file;

  if (!(d = get_dir_ptr(dir)))
    return (1);
  my_printf("Total : %d\n", get_total_blocks(dir));
  while ((e = readdir(d)))
    {
      file = format_dir(dir, e->d_name);
      if (e->d_name[0] != '.')
	{
	  if (stat(file, &s) == -1)
	    {
	      closedir(d);
	      return (1);
	    }
	  format_line(e->d_name, &s, t);
	}
      free(file);
    }
  closedir(d);
  my_printf("\n\n");
  return (0);
}
Beispiel #3
0
/*
Return 1st free block. Note that, each bit in the bit map array will represent a block.
So, say 132 blocks are filled and we are supposed to insert in the the 133rd block.
So it means that memory_map[0] and memory_map[1] will be all F's. memory_map[2] will be
0xFFFFFFFF000011111. Thus for j=5, memory_map[2] & 1<<5, the bit will be 0. Hence, we return
2*64 + 5 = 133rd block as free.
*/
int mmgr_get_first_free(){
  uint32_t i,j;
  uint64_t bit;
  for(i=0; i< (get_total_blocks() / 64); i++){
    if(mmgr_memory_map[i] != 0xFFFFFFFFFFFFFFFF){
      for(j=0; j<64; j++){
        bit = 1<<j;
        if( !(mmgr_memory_map[i] & bit) )
          return i*64 + j;
      }
    }
  }
  return -1;
}
Beispiel #4
0
void		print_total(char **files, char *flags, char *folder)
{
	int				blocks_size;
	struct stat		*file_stat;

	blocks_size = 0;
	file_stat = NULL;
	if (!check_l_or_1(flags))
	{
		blocks_size = get_total_blocks(files, file_stat, folder);
		if (blocks_size > 0 || ft_strchr(flags, 'a') || files[0])
		{
			ft_putstr("total ");
			ft_putnbr(blocks_size);
			ft_putstr("\n");
		}
	}
}
Beispiel #5
0
void		read_dir(t_all *all, char *str)
{
	DIR				*dir;
	struct dirent	*file;
	struct stat		stats;

	dir = opendir(str);
	while ((file = readdir(dir)))
	{
		stat(file->d_name, &stats);
		if (file->d_name[0] == '.')
		{
			if (all->flag_a)
				create_list(file->d_name, &all->list, all);
		}
		else
			create_list(file->d_name, &all->list, all);
	}
	if (!all->flag_f)
		tri_lst(&all->list, all);
	flag_r_detect(all);
	get_total_blocks(all);
	closedir(dir);
}
Beispiel #6
0
void print_usable_system_memory(){
        uint16_t i;
        for(i=0; i<usable_mem_counter; i++){
             printf("Base %x\tLength %x\ttype %d\n",sys_usable_memory[i].base,sys_usable_memory[i].length,sys_usable_memory[i].type); 
        } 
        printf("\n\n Totable usable memory of the system = %d\tTotal number of blocks = %d\n",get_total_usable_memory(),get_total_blocks());
}
Beispiel #7
0
uint64_t get_total_usable_blocks(){
        return (get_total_blocks() - get_used_blocks());
}
Beispiel #8
0
void mmgr_print_memory_status(){
  printf("\nTotal usable memory = %d\n",get_total_usable_memory());
  printf("Total number of blocks = %d\n",get_total_blocks());
  printf("Total number of used blocks = %d\n",get_used_blocks());
  printf("Total number of usable blocks = %d\n\n",get_total_usable_blocks()); 
}