Esempio n. 1
0
struct cached_block* get_free_cache_buff(){
	if(INODE_DEBUG) printf("get_free_cache_buff()\n");
	int idx = bitmap_scan_and_flip(cache_bitmap, 0, 1, FREE);
	
	if(idx != BITMAP_ERROR){
		
		struct cached_block* newblock = buffcache + idx;
		if(INODE_DEBUG) printf("get_free_cache_buff(): idx %d buffcache %x newblock %x buffcache+BUFF_CACHE_SIZE %x\n", idx, buffcache, newblock, buffcache+N_BUFFERS);
		
		memset(newblock, 0, sizeof(struct cached_block));
		
		list_push_front(&buffcachelist, &newblock->elem);
		
		
		return newblock;
	}
	else{
		struct cached_block* last_block = list_entry(list_back(&buffcache), struct cached_block, elem);
		cache_flush(NULL, last_block->sector);
		list_remove(&last_block->elem);
		traverse_buffcachelist();
		list_push_front(&buffcachelist, &last_block->elem);
		memset(last_block->data, 0, BLOCK_SECTOR_SIZE);
		last_block->inode=NULL;
		last_block->sector=0;
		if(INODE_DEBUG) printf("get_free_cache_buff(): idx %d buffcache %x lastblock %x buffcache+BUFF_CACHE_SIZE %x\n", idx, buffcache, last_block, buffcache+N_BUFFERS);
		return last_block;
	}
}
Esempio n. 2
0
/**
 * @brief tests the push/pop functions of the list module
 * @return 0 if success
 * @return 1 if failture
 */
int test_list_push_pop()
{
    list_t *testList = list_create();

    int a = 12345;
    int b = 98765;
    int c = 54321;
    int d = 56789;
    int *resa, *resb, *resc, *resd;

    list_push_front(testList, &b);
    list_push_front(testList, &a);
    list_push_back(testList, &c);
    list_push_back(testList, &d);

    resa = list_pop_front(testList);
    resb = list_pop_front(testList);
    resd = list_pop_back(testList);
    resc = list_pop_back(testList);

    if(*resa != a || *resb != b || *resc != c || *resd != d)
    {
        printf("list push and pop front and back: failture\n");
        return 1;
    }

    list_destroy(testList);

    return 0;
}
Esempio n. 3
0
int main()
{
    struct list* test_list = list_create();

    char* str1 = "string_1";
    list_push_front(test_list, str1);

    char* str2 = "string_2";
    list_push_front(test_list, str2);

    char* str3 = "string_3";
    list_push_front(test_list, str3);

    list_push_front(test_list, "string_4");

    /*list_bubble_sort(test_list, (list_compare)strcmp);*/

    list_reverse(test_list);

    /*list_remove(test_list, test_list->first);*/

    list_print(test_list);

    /*list_clear(test_list);*/
    return 0;
}
Esempio n. 4
0
list* search_breadth_first(void* state,
                           void* state_world,
                           search_is_goal state_goal_func,
                           search_gen_successors state_gen_func,
                           search_link_parent state_link_func,
                           search_goal_backtrace state_back_func,
                           hash_func state_hash_alg,
                           generic_comp state_comp_func,
                           generic_cpy state_copy_func,
                           generic_op state_free_func) {
    int found;
    void* current_state, *successor_state;
    list* state_queue, *successor_list, *path;
    hash_table* state_closed_set;

    state_queue = list_create(NULL,
                              NULL,
                              state_free_func);

    state_closed_set = hash_table_create(89,
                                         .75,
                                         state_hash_alg,
                                         state_comp_func,
                                         state_copy_func,
                                         state_free_func);
    current_state = state;
    list_push_front(state_queue, current_state);
    hash_table_insert(state_closed_set, current_state, 0);
    path = NULL;
    found = 0;
    while(!list_is_empty(state_queue) && !found) {
        current_state = list_back(state_queue);
        list_deque(state_queue);
        if(state_goal_func(current_state, state_world)) {
            current_state = state_copy_func(current_state);
            path = state_back_func(current_state);
            found = 1;
        } else {
            successor_list = state_gen_func(current_state, state_world);
            while(!list_is_empty(successor_list)) {
                successor_state = list_front(successor_list);
                if(!hash_table_contains(state_closed_set, successor_state)) {
                    state_link_func(successor_state, current_state);
                    hash_table_insert(state_closed_set, successor_state, 0);
                    list_push_front(state_queue, successor_state);
                    list_pop(successor_list);
                } else {
                    list_remove_front(successor_list);
                }
            }
            list_kill(successor_list);
        }
    }
    hash_table_kill(state_closed_set);
    list_dissolve(state_queue);
    return path;
}
Esempio n. 5
0
File: bfs.c Progetto: wqferr/P-A-T-H
list *_solver_bfs_path(void *data, const maze *m) {
	list *path = list_create(sizeof(vec2));
	vec2 cur = maze_get_end(m);
	bfs_data bfs = *((bfs_data *) data);

	while (vec2_comp(cur, maze_get_start(m)) != 0) {
		list_push_front(path, &cur);
		map_get(bfs.parent, &cur, &cur);
	}
	list_push_front(path, &cur);

	return path;
}
TEST(INSERTION, IN_HEAD) {
  list_t* list = list_create();

  // Inserting elements in head.
  node_t* foo = list_push_front(list, (void*) "foo");
  node_t* bar = list_push_front(list, (void*) "bar");

  EXPECT_EQ(list_get_size(list), 2);
  EXPECT_STREQ((const char*) foo->element, "foo");
  EXPECT_STREQ((const char*) bar->element, "bar");
  EXPECT_EQ(list->head, bar);
  EXPECT_EQ(list->tail, foo);
  list_destroy(list);
}
Esempio n. 7
0
/**
 * @brief tests the is_empty function of the list module
 * @return 0 if success
 * @return 1 if failture
 */
int test_list_is_empty()
{
    list_t *testList = list_create();

    if(!list_is_empty(testList))
    {
        printf("list is empty: failture\n");
        return 1;
    }

    int i;

    for(i = 0; i < FILL_TEST_NUMBER; i++)
        list_push_front(testList, testList);

    for(i = 0; i < FILL_TEST_NUMBER; i++)
        list_pop_front(testList);

    if(!list_is_empty(testList))
    {
        printf("list is empty: failture\n");
        return 1;
    }

    list_destroy(testList);

    return 0;
}
Esempio n. 8
0
/* Acquires LOCK, sleeping until it becomes available if
   necessary.  The lock must not already be held by the current
   thread.

   This function may sleep, so it must not be called within an
   interrupt handler.  This function may be called with
   interrupts disabled, but interrupts will be turned back on if
   we need to sleep. */
void
lock_acquire (struct lock *lock)
{
  ASSERT (lock != NULL);
  ASSERT (!intr_context ());
  ASSERT (!lock_held_by_current_thread (lock));

  enum intr_level old_level = intr_disable ();

  if (lock->holder != NULL) /* If the lock is being held. */
  {
    /* Updates current thread's lock_to_acquire attribute,
       adds itself to the lock holder's donors list and
       donates priority. */
    thread_current ()->lock_to_acquire = lock;
    list_push_front (&lock->holder->priority_donors,
                     &thread_current ()->donor);
    priority_donation ();
  }

  sema_down (&lock->semaphore);

  /* The lock has been acquired: current thread is not waiting
     for it anymore. */
  thread_current ()->lock_to_acquire = NULL;
  lock->holder = thread_current ();

  intr_set_level (old_level);
}
Esempio n. 9
0
/* Reads an inode from SECTOR
   and returns a `struct inode' that contains it.
   Returns a null pointer if memory allocation fails. */
struct inode *
inode_open (block_sector_t sector)
{
    struct list_elem *e;
    struct inode *inode;

    /* Check whether this inode is already open. */
    for (e = list_begin (&open_inodes); e != list_end (&open_inodes);
            e = list_next (e))
    {
        inode = list_entry (e, struct inode, elem);
        if (inode->sector == sector)
        {
            //printf("sector : %d has same sector\n",sector);
            inode_reopen (inode);
            return inode;
        }
    }

    /* Allocate memory. */
    inode = malloc (sizeof *inode);
    if (inode == NULL)
        return NULL;

    /* Initialize. */
    list_push_front (&open_inodes, &inode->elem);
    inode->sector = sector;
    inode->open_cnt = 1;
    inode->deny_write_cnt = 0;
    inode->removed = false;
    inode->extension = false;
    block_read (fs_device, inode->sector, &inode->data);
    return inode;
}
Esempio n. 10
0
//将定时器按时间插入对应位置
static int insertTimer(int id)
{
	clist* list_t = list_begin(&g_listTimerWork);
	st_timer* timer_t = (st_timer*)list_t;
	st_timer* TimerVal = &g_timerArray[id];
	
	//插入到头部
	if (list_empty(&g_listTimerWork))
	{
		list_push_front(&g_listTimerWork, &TimerVal->list);
		return 1;
	}

	//插入到中间
	while(list_end(&g_listTimerWork) != list_t/* && !list_empty(list_t)*/)
	{
		timer_t = (st_timer*)list_t;
		if(cmptime(&timer_t->tv, &TimerVal->tv))
		{
			list_insert(list_t, &TimerVal->list);
			return 2;
		}
		list_t = list_t->next;
	}
	//插入到尾部
	list_push_back(&g_listTimerWork, &TimerVal->list);
	return 3;
}
Esempio n. 11
0
void
uart_sampler_hash_insert(hash_t *hash, hash_elem_t *elem)
{
    list_t *bin = &hash->bins[hash->hash_func(elem)];

    list_push_front(bin, elem);
}
Esempio n. 12
0
int (list_insert_before) (
                         SCL_list_t     a_list,
                         SCL_iterator_t a_iterator,
                         const void*    a_data
                         )
   {
   S_SCL_list_t* const list = a_list;
   S_node_t* ilink = (S_node_t*)a_iterator;
   S_node_t* node;

   if (ilink == list->head) return list_push_front (a_list, a_data);

   node = SCL_ALLOCATOR (sizeof(S_node_t));
   if (node == NULL) return SCL_NOMEM;

   node->data = a_data;
   PRED(node) = PRED(ilink);
   SUCC(node) = ilink;

   SUCC(PRED(ilink)) = node;
   PRED(ilink) = node;

   list->count += 1;

   return SCL_OK;
   }
Esempio n. 13
0
int (list_insert) (SCL_list_t a_list, size_t a_index, const void* a_data)
   {
   S_SCL_list_t* const list = a_list;
   S_node_t* ilink = list->head;
   S_node_t* node;

   if (a_index == 0) return list_push_front (a_list, a_data);
   if (a_index == a_list->count) return list_push_back (a_list, a_data);
   if (a_index > a_list->count) return SCL_NOTFOUND;

   node = SCL_ALLOCATOR (sizeof(S_node_t));
   if (node == NULL) return SCL_NOMEM;

   node->data = a_data;

   while (--a_index > 0) ilink = SUCC(ilink);

   PRED(node) = ilink;
   SUCC(node) = SUCC(ilink);
   PRED(SUCC(ilink)) = node;
   SUCC(ilink) = node;

   list->count += 1;

   return SCL_OK;
   }
Esempio n. 14
0
/**
*  Init of the fuse receive buffer distributor

   @param count: number of buffer to setup
   @param size: size of each buffer

   @retval 0 on success
   @retval -1 on error (see errno )
*/
int rozofs_fuse_init_rcv_buffer_pool(int count,int size)
{
   int effective_size = size+sizeof(list_t);
   int i;
   rozofs_fuse_rcv_buf_t *p_rcv_buf;
   
   /*
   ** init of the head
   */
    list_init(&rozofs_fuse_rcv_buf_head);
    rozofs_fuse_rcv_buf_count = count;
    
    for (i = 0; i < count;i++)
    {
       p_rcv_buf = memalign(4096,effective_size);
       if (p_rcv_buf== NULL)
       {
          errno = ENOMEM;
	  return -1;
       }
       list_init(&p_rcv_buf->list);
       list_push_front(&rozofs_fuse_rcv_buf_head,&p_rcv_buf->list);        
    }
    return 0;
}
Esempio n. 15
0
int main() {
    List *list = list_create(sizeof(int));

    printf("List: ");
    int data = 1;
    list_push_back(list, &data);
    data = 3;
    list_push_back(list, &data);
    data = 5;
    list_push_back(list, &data);
    data = 0;
    list_push_back(list, &data);
    list_print(list, intPrinter);

    printf("\r\nRevd: ");
    list_reverse(list);
    list_print(list, intPrinter);

    data = -1;
    list_push_front(list, &data);
    printf("\r\nFron: ");
    list_print(list, intPrinter);

    list_pop_back(list, &data);
    printf("\r\nPopb: ");
    list_print(list, intPrinter);

    list_pop_front(list, &data);
    printf("\r\nPopf: ");
    list_print(list, intPrinter);

    printf("\r\n");

    return 0;
}
Esempio n. 16
0
/* Open system call. */
static int
sys_open (const char *ufile) 
{
  char *kfile = copy_in_string (ufile);
  struct file_descriptor *fd;
  int handle = -1;
 
  fd = calloc (1, sizeof *fd);
  if (fd != NULL)
    {
      struct inode *inode = filesys_open (kfile);
      if (inode != NULL)
        {
          if (inode_get_type (inode) == FILE_INODE)
            fd->file = file_open (inode);
          else
            fd->dir = dir_open (inode);
          if (fd->file != NULL || fd->dir != NULL)
            {
              struct thread *cur = thread_current ();
              handle = fd->handle = cur->next_handle++;
              list_push_front (&cur->fds, &fd->elem);
            }
          else 
            {
              free (fd);
              inode_close (inode);
            }
        }
    }
  
  palloc_free_page (kfile);
  return handle;
}
Esempio n. 17
0
void		create_incantation(t_server *infos, t_mail *msg)
{
  t_incantation	*new_incantation;

  if (can_incantation(infos, msg->from) == FAILURE)
    {
      msg->from->action.clock = clock() * 1000 / CLOCKS_PER_SEC
	+ 1000 / infos->exec_delay;
      return ;
    }
  if ((new_incantation = malloc(sizeof(t_incantation))) == NULL)
    return ;
  if ((new_incantation->player = malloc(sizeof(t_player *)
					* (g_nb_player[msg->from->level - 1]
					   + 1))) == NULL)
    {
      free(new_incantation);
      return ;
    }
  if (list_push_front(&infos->incantation_list, new_incantation) == FAILURE)
    {
      free(new_incantation->player);
      free(new_incantation);
      return ;
    }
  end_create_incantation(infos, msg, new_incantation);
}
Esempio n. 18
0
int main() {

    node* n = NULL;
    node* next = NULL;
    int i;
    
    for (i = 0; i < 10; i++) {
        int* val = malloc(sizeof(int));
        *val = i;
        next = list_push_back(next, val);
        if (i == 0)
            // store head
            n = next;
    }
    for (i = 0; i < 10; i++) {
        int* val = malloc(sizeof(int));
        *val = i;
        n = list_push_front(n, val);
    }

    next = n;
    do {
        fprintf(stdout,"%d\n", * (int*) next->data); 
        next = next->next;
    }while(next);

    list_destroy(n, free);
    return 0;
}
Esempio n. 19
0
/* Reads an inode from SECTOR
   and returns a `struct inode' that contains it.
   Returns a null pointer if memory allocation fails. */
struct inode *
inode_open (block_sector_t sector)
{
  struct list_elem *e;
  struct inode *inode;

  /* Check whether this inode is already open. */
  for (e = list_begin (&open_inodes); e != list_end (&open_inodes);
       e = list_next (e))
    {
      inode = list_entry (e, struct inode, elem);
      if (inode->sector == sector)
        {
          inode_reopen (inode);
          return inode;
        }
    }

  /* Allocate memory. */
  inode = malloc (sizeof *inode);
  if (inode == NULL)
    return NULL;

  /* Initialize. */
  list_push_front (&open_inodes, &inode->elem);
  inode->sector = sector;
  inode->open_cnt = 1;
  inode->deny_write_cnt = 0;
  inode->removed = false;
  cache_read (fs_cache, inode->sector, &inode->data, 0, BLOCK_SECTOR_SIZE);
  return inode;
}
Esempio n. 20
0
/* Reads an inode from SECTOR
   and returns a `struct inode' that contains it.
   Returns a null pointer if memory allocation fails. */
struct inode *
inode_open (block_sector_t sector)
{
	if(INODE_DEBUG || FILE_DEBUG) printf("INODE: opening inode %u\n", sector);

  struct list_elem *e;
  struct inode *inode;

  /* Check whether this inode is already open. */
  for (e = list_begin (&open_inodes); e != list_end (&open_inodes);
       e = list_next (e)) 
    {
      inode = list_entry (e, struct inode, elem);
      if (inode->sector == sector) 
        {
          inode_reopen (inode);
          return inode; 
        }
    }

  /* Allocate memory. */
  inode = malloc (sizeof *inode);
  if (inode == NULL)
    return NULL;

  /* Initialize. */
  list_push_front (&open_inodes, &inode->elem);
  inode->sector = sector;
  inode->open_cnt = 1;
  inode->deny_write_cnt = 0;
  inode->removed = false;
  lock_init(&inode->lock);	

  return inode;
}
Esempio n. 21
0
static void
fillMap(int start_i, int start_j, gameObjectType type) {
  GameObject*	t;
  int		id;

  if (type != 0) {
    t = instanciateGameObject(type, start_i, start_j);
    gameEngine->_gameObjects = list_push_front(GameObjectList, gameEngine->_gameObjects, t);
    id = t->id;
  } else {
    id = -1;
  }

  int end_i = start_i + 3;
  int end_j = start_j + 3;
  int save_j = start_j;

  while (start_i != end_i) {
    start_j = save_j;
    while (start_j != end_j) {
      gameEngine->_map._map[start_i][start_j] = id;
      ++start_j;
    }
    ++start_i;
  }
}
Esempio n. 22
0
/* Open system call. */
static int
sys_open (const char *ufile) 
{
  char *kfile = copy_in_string (ufile);
  struct file_descriptor *fd;
  int handle = -1;
 
  fd = malloc (sizeof *fd);
  if (fd != NULL)
    {
      lock_acquire (&fs_lock);
      fd->file = filesys_open (kfile);
      if (fd->file != NULL)
        {
          struct thread *cur = thread_current ();
          handle = fd->handle = cur->next_handle++;
          list_push_front (&cur->fds, &fd->elem);
        }
      else 
        free (fd);
      lock_release (&fs_lock);
    }
  
  palloc_free_page (kfile);
  return handle;
}
Esempio n. 23
0
/* Removes 'e' from the 'ml' hash table.  'e' must not already be on the free
 * list. */
static void
free_mac_entry(struct mac_learning *ml, struct mac_entry *e)
{
    list_remove(&e->hash_node);
    list_remove(&e->lru_node);
    list_push_front(&ml->free, &e->lru_node);
}
Esempio n. 24
0
/* 
 --------------------------------------------------------------------
 Acquires LOCK, sleeping until it becomes available if
   necessary.  The lock must not already be held by the current
   thread.

   This function may sleep, so it must not be called within an
   interrupt handler.  This function may be called with
   interrupts disabled, but interrupts will be turned back on if
   we need to sleep. 
 NOTE: if we cannot aquire the lock and we are in regular priority
    donation scheduling, then we invoke the call to donate our
    priority. Once we move past the semaphore, we have aquired the 
    lock, and thus add it to our list of locks_held, so that this
    thread can properly recieve priortity donations. 
 --------------------------------------------------------------------
 */
void
lock_acquire (struct lock *lock)
{
    ASSERT (lock != NULL);
    ASSERT (!intr_context ());
    ASSERT (!lock_held_by_current_thread (lock));
    
    enum intr_level old_level = intr_disable();
    
    if (!thread_mlfqs) { 
        if (lock->holder != NULL) {
            thread_current()->lock_waiting_on = lock;
            //donate_priority();
        }
    }
    
    sema_down (&lock->semaphore);
    
    if (!thread_mlfqs) {
        lock->priority = PRI_MIN;
        list_push_front(&(thread_current()->locks_held), &(lock->elem));
        thread_current()->lock_waiting_on = NULL;
    }
    lock->holder = thread_current ();
    
    intr_set_level(old_level);
}
Esempio n. 25
0
sid_t session_create (void *(*readlink_cb)(void *), cb_arg_t *arg)
{
  session_t * new_s = NULL;
  sid_t ret_sid;

  new_s = (session_t *) malloc (sizeof (session_t));

  if (new_s == NULL)
    return -1;

  new_s->sid = ++last_sid;
  new_s->uid = -1;
  new_s->last_lid = 0;

  list_init (&new_s->link_list);

  new_s->readlink_cb = readlink_cb;
  new_s->arg = arg;
  
  ret_sid = new_s->sid;

  pthread_mutex_lock (&session_mutex);
  list_push_front (&session_list, &new_s->elem);
  pthread_mutex_unlock (&session_mutex);

  return ret_sid;
}
Esempio n. 26
0
void		*list_cpush_front(void *head, size_t size)
{
  t_list	*rnew;

  if ((rnew = list_create(size)) == NULL)
    return (NULL);
  return (list_push_front(rnew, head));
}
Esempio n. 27
0
/* Attempts to make 'ml' learn from the fact that a frame from 'src_mac' was
 * just observed arriving from 'src_port' on the given 'vlan'.
 *
 * Returns nonzero if we actually learned something from this, zero if it just
 * confirms what we already knew.  The nonzero return value is the tag of flows
 * that now need revalidation.
 *
 * The 'vlan' parameter is used to maintain separate per-VLAN learning tables.
 * Specify 0 if this behavior is undesirable.
 *
 * 'lock_type' specifies whether the entry should be locked or existing locks
 * are check. */
tag_type
mac_learning_learn(struct mac_learning *ml,
                   const uint8_t src_mac[ETH_ADDR_LEN], uint16_t vlan,
                   uint16_t src_port, enum grat_arp_lock_type lock_type)
{
    struct mac_entry *e;
    struct list *bucket;

    if (!is_learning_vlan(ml, vlan)) {
        return 0;
    }

    if (eth_addr_is_multicast(src_mac)) {
        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30, 30);
        VLOG_DBG_RL(&rl, "multicast packet source "ETH_ADDR_FMT,
                    ETH_ADDR_ARGS(src_mac));
        return 0;
    }

    bucket = mac_table_bucket(ml, src_mac, vlan);
    e = search_bucket(bucket, src_mac, vlan);
    if (!e) {
        if (!list_is_empty(&ml->free)) {
            e = mac_entry_from_lru_node(ml->free.next);
        } else {
            e = mac_entry_from_lru_node(ml->lrus.next);
            list_remove(&e->hash_node);
        }
        memcpy(e->mac, src_mac, ETH_ADDR_LEN);
        list_push_front(bucket, &e->hash_node);
        e->port = -1;
        e->vlan = vlan;
        e->tag = make_unknown_mac_tag(ml, src_mac, vlan);
        e->grat_arp_lock = TIME_MIN;
    }

    if (lock_type != GRAT_ARP_LOCK_CHECK || time_now() >= e->grat_arp_lock) {
        /* Make the entry most-recently-used. */
        list_remove(&e->lru_node);
        list_push_back(&ml->lrus, &e->lru_node);
        e->expires = time_now() + MAC_ENTRY_IDLE_TIME;
        if (lock_type == GRAT_ARP_LOCK_SET) {
            e->grat_arp_lock = time_now() + MAC_GRAT_ARP_LOCK_TIME;
        }

        /* Did we learn something? */
        if (e->port != src_port) {
            tag_type old_tag = e->tag;
            e->port = src_port;
            e->tag = tag_create_random();
            COVERAGE_INC(mac_learning_learned);
            return old_tag;
        }
    }

    return 0;
}
Esempio n. 28
0
void push(char *args, List *list, int pd)
{
	int n;
	if (get_one_arg(args, &n))
	{
		if (pd == pd_front)
			list_push_front(list, n);
		else
			list_push_back(list, n);
	}
}
Esempio n. 29
0
File: testing.c Progetto: Exy13/Tp-C
struct list* build_int_list(int len, struct data storage[]) 
{
  struct list          *sentinel;
  sentinel = malloc(sizeof (struct list));
  list_init(sentinel);
  for (int i = 0; i < len; ++i) {
    storage[i].value = i;
    list_push_front(sentinel, &(storage[i].list_));
  }
  return sentinel;
}
Esempio n. 30
0
/* Tries to allocate and lock a frame for PAGE.
   Returns the frame if successful, false on failure. */
struct frame *
frame_alloc_and_lock (struct page *page) 
{
void *temp;

    temp=palloc_get_page(PAL_USER);
   if(temp!=NULL)
     {
      struct frame *f=malloc(sizeof(struct frame));
      lock_init(&f->lock);
      f->page=page;
      f->base=temp;
     lock_acquire(&framelock);
     list_push_front(&frametable,&f->elem);
     lock_release(&framelock);
      return f;
     }
   
      
struct list_elem *e1;
e1=list_begin(&frametable);

while(1)
{
lock_acquire(&framelock);
struct frame *fr;
fr=malloc(sizeof(struct frame));
/*fr=list_entry(e1,struct frame,elem);*/
/* bool 
temp=pagedir_is_accessed((fr->page->thread)->pagedir,fr->page->addr);
  if(temp)
   {        
pagedir_set_accessed((fr->page->thread)->pagedir,fr->page->addr,false);*/  
     e1=list_next(e1);
        if(e1==list_end(&frametable))
          {
          e1=list_begin(&frametable);
          }    
     continue;
    }
struct frame *fr;
  if(fr->page->iswrite)
     {/* fr->page->mode=swap_out(*/
      }
  else
     {
     }
    fr->page=page;  

   lock_release(&framelock);
   return fr;
      

}