Changeset 6efec7e3 in mainline for uspace/srv/sysman/unit.c
- Timestamp:
- 2019-08-03T07:38:34Z (6 years ago)
- Children:
- 59ba708
- Parents:
- 4fe7fcb
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-03-17 19:54:13)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-03 07:38:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/sysman/unit.c
r4fe7fcb r6efec7e3 6 6 #include <stdlib.h> 7 7 8 #include "log.h" 8 9 #include "unit.h" 10 11 /** Virtual method table for each unit type */ 12 static unit_ops_t *unit_type_vmts[] = { 13 [UNIT_TARGET] = &unit_tgt_ops, 14 [UNIT_MOUNT] = &unit_mnt_ops, 15 [UNIT_CONFIGURATION] = &unit_cfg_ops 16 }; 9 17 10 18 static void unit_init(unit_t *unit, unit_type_t type) … … 12 20 assert(unit); 13 21 22 memset(unit, 0, sizeof(unit_t)); 14 23 link_initialize(&unit->units); 15 24 … … 21 30 list_initialize(&unit->dependants); 22 31 list_initialize(&unit->dependencies); 32 33 unit_type_vmts[unit->type]->init(unit); 23 34 } 24 35 … … 33 44 34 45 /** Release resources used by unit structure */ 35 void unit_destroy(unit_t **unit )46 void unit_destroy(unit_t **unit_ptr) 36 47 { 37 if (*unit == NULL) 48 unit_t *unit = *unit_ptr; 49 if (unit == NULL) 38 50 return; 51 52 unit_type_vmts[unit->type]->destroy(unit); 39 53 /* TODO: 40 54 * edges, 41 * specific unit data,42 55 * check it's not an active unit, 43 56 * other resources to come 44 57 */ 45 free(*unit); 46 *unit = NULL; 58 free(unit); 59 unit_ptr = NULL; 60 } 61 62 void unit_set_state(unit_t *unit, unit_state_t state) 63 { 64 fibril_mutex_lock(&unit->state_mtx); 65 unit->state = state; 66 fibril_condvar_broadcast(&unit->state_cv); 67 fibril_mutex_unlock(&unit->state_mtx); 47 68 } 48 69 … … 54 75 int unit_start(unit_t *unit) 55 76 { 56 // TODO actually start the unit 57 printf("Starting unit of type %i\n", unit->type); 58 return EOK; 77 sysman_log(LVL_DEBUG, "%s(%p)", __func__, unit); 78 return unit_type_vmts[unit->type]->start(unit); 59 79 }
Note:
See TracChangeset
for help on using the changeset viewer.