void minix_inode_init(void) { int i; /* init inode slab */ minix_inode_slab = alloc_slab(sizeof(struct minix_inode)); if (!minix_inode_slab) panic("No enough memory for minix inode slab"); /* init hash table */ for (i = 0; i < MINIX_INODE_HASH_SIZE; i++) hlist_head_init(&minix_inode_htable[i]); }
void block_init(void) { int i; /* init block buffer allocator */ block_slab = alloc_slab(sizeof(struct block)); if (!block_slab) panic("No memory for block slab"); /* init block buffer hash table */ for (i = 0; i < BLOCK_HASH_SIZE; i++) hlist_head_init(&block_htable[i]); hd_init(); block_test(); }
void udp_init(void) { struct hash_slot *slot; int i; /* init udp hash table */ for (slot = udp_hash_slot(i = 0); i < UDP_HASH_SIZE; i++, slot++) { hlist_head_init(&slot->head); slot->used = 0; } udp_table.best_slot = 0; udp_table.best_update = UDP_BEST_UPDATE; pthread_mutex_init(&udp_table.mutex, NULL); /* udp ip id */ udp_id = 0; }
/* ****************************************************************************** * task_base_init -- *//** * * \brief This routine allocates related resource for task management. * * \retval OSW_OK Success * \retval OSW_ERROR Failure * *****************************************************************************/ int task_base_init(void) { /* create task base and initialize it */ tsbase = (task_base *)malloc(sizeof(task_base)); if (tsbase == NULL) { printf("Fail to memory allocation!\r\n"); return OSW_ERROR; } memset(tsbase, 0, sizeof(task_base)); pthread_mutex_init(&tsbase->lock, NULL); hlist_head_init(&tsbase->task_list); return OSW_OK; }