Changeset dda2602 in mainline for uspace/srv/sysman/configuration.c


Ignore:
Timestamp:
2019-08-03T09:41:07Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
dd5c623
Parents:
c0e4fc50
git-author:
Michal Koutný <xm.koutny+hos@…> (2015-05-08 11:10:06)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-03 09:41:07)
Message:

sysman: Create units to start up to compositor

  • add necessary units to support basic GUI (barber, vterm)
  • lacking autostart is compensated with explicit dependencies
  • IPC_FLAG_AUTOSTART in compositor and locsrv fix
  • paths to v* binaries
  • refactored job closure creation

Conflicts:

boot/Makefile.common
uspace/app/vlaunch/vlaunch.c
uspace/srv/hid/compositor/compositor.c
uspace/srv/locsrv/locsrv.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/sysman/configuration.c

    rc0e4fc50 rdda2602  
    3838#include "log.h"
    3939
    40 static hash_table_t units;
     40LIST_INITIALIZE(units);
     41
     42static hash_table_t units_by_name;
    4143
    4244/* Hash table functions */
    43 static size_t units_ht_hash(const ht_link_t *item)
     45static size_t units_by_name_ht_hash(const ht_link_t *item)
    4446{
    4547        unit_t *unit =
    46             hash_table_get_inst(item, unit_t, units);
     48            hash_table_get_inst(item, unit_t, units_by_name);
    4749        return hash_string(unit->name);
    4850}
    4951
    50 static size_t units_ht_key_hash(void *key)
     52static size_t units_by_name_ht_key_hash(void *key)
    5153{
    5254        return hash_string((const char *)key);
    5355}
    5456
    55 static bool units_ht_equal(const ht_link_t *item1, const ht_link_t *item2)
     57static bool units_by_name_ht_equal(const ht_link_t *item1, const ht_link_t *item2)
    5658{
    5759        return str_cmp(
    58             hash_table_get_inst(item1, unit_t, units)->name,
    59             hash_table_get_inst(item2, unit_t, units)->name) == 0;
    60 }
    61 
    62 static bool units_ht_key_equal(void *key, const ht_link_t *item)
     60            hash_table_get_inst(item1, unit_t, units_by_name)->name,
     61            hash_table_get_inst(item2, unit_t, units_by_name)->name) == 0;
     62}
     63
     64static bool units_by_name_ht_key_equal(void *key, const ht_link_t *item)
    6365{
    6466        return str_cmp((const char *)key,
    65             hash_table_get_inst(item, unit_t, units)->name) == 0;
    66 }
    67 
    68 
    69 static hash_table_ops_t units_ht_ops = {
    70         .hash            = &units_ht_hash,
    71         .key_hash        = &units_ht_key_hash,
    72         .equal           = &units_ht_equal,
    73         .key_equal       = &units_ht_key_equal,
     67            hash_table_get_inst(item, unit_t, units_by_name)->name) == 0;
     68}
     69
     70
     71static hash_table_ops_t units_by_name_ht_ops = {
     72        .hash            = &units_by_name_ht_hash,
     73        .key_hash        = &units_by_name_ht_key_hash,
     74        .equal           = &units_by_name_ht_equal,
     75        .key_equal       = &units_by_name_ht_key_equal,
    7476        .remove_callback = NULL // TODO realy unneeded?
    7577};
     
    7981void configuration_init(void)
    8082{
    81         hash_table_create(&units, 0, 0, &units_ht_ops);
     83        hash_table_create(&units_by_name, 0, 0, &units_by_name_ht_ops);
    8284}
    8385
     
    8991        sysman_log(LVL_DEBUG2, "%s('%s')", __func__, unit_name(unit));
    9092
    91         if (hash_table_insert_unique(&units, &unit->units)) {
     93        if (hash_table_insert_unique(&units_by_name, &unit->units_by_name)) {
     94                list_append(&unit->units, &units);
    9295                return EOK;
    9396        } else {
     
    102105static bool configuration_commit_unit(ht_link_t *ht_link, void *arg)
    103106{
    104         unit_t *unit = hash_table_get_inst(ht_link, unit_t, units);
     107        unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name);
    105108        // TODO state locking?
    106109        if (unit->state == STATE_EMBRYO) {
     
    116119}
    117120
    118 /** Marks newly added units as usable (via state change) */
     121/** Marks newly added units_by_name as usable (via state change) */
    119122void configuration_commit(void)
    120123{
     
    122125
    123126        /*
    124          * Apply commit to all units, each commited unit commits its outgoing
     127         * Apply commit to all units_by_name, each commited unit commits its outgoing
    125128         * deps, thus eventually commiting all embryo deps as well.
    126129         */
    127         hash_table_apply(&units, &configuration_commit_unit, NULL);
     130        hash_table_apply(&units_by_name, &configuration_commit_unit, NULL);
    128131}
    129132
    130133static bool configuration_rollback_unit(ht_link_t *ht_link, void *arg)
    131134{
    132         unit_t *unit = hash_table_get_inst(ht_link, unit_t, units);
     135        unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name);
    133136
    134137        list_foreach_safe(unit->dependencies, cur_link, next_link) {
     
    141144
    142145        if (unit->state == STATE_EMBRYO) {
    143                 hash_table_remove_item(&units, ht_link);
     146                hash_table_remove_item(&units_by_name, ht_link);
     147                list_remove(&unit->units);
    144148                unit_destroy(&unit);
    145149        }
     
    148152}
    149153
    150 /** Remove all uncommited units and edges from configuratio
     154/** Remove all uncommited units_by_name and edges from configuratio
    151155 *
    152156 * Memory used by removed object is released.
     
    156160        sysman_log(LVL_DEBUG2, "%s", __func__);
    157161
    158         hash_table_apply(&units, &configuration_rollback_unit, NULL);
     162        hash_table_apply(&units_by_name, &configuration_rollback_unit, NULL);
    159163}
    160164
     
    162166{
    163167        bool *has_error_ptr = arg;
    164         unit_t *unit = hash_table_get_inst(ht_link, unit_t, units);
     168        unit_t *unit = hash_table_get_inst(ht_link, unit_t, units_by_name);
    165169
    166170        list_foreach(unit->dependencies, dependencies, unit_dependency_t, dep) {
     
    187191}
    188192
    189 /** Resolve unresolved dependencies between any pair of units
     193/** Resolve unresolved dependencies between any pair of units_by_name
    190194 *
    191195 * @return EOK      on success
     
    197201
    198202        bool has_error = false;
    199         hash_table_apply(&units, &configuration_resolve_unit, &has_error);
     203        hash_table_apply(&units_by_name, &configuration_resolve_unit, &has_error);
    200204
    201205        return has_error ? ENOENT : EOK;
     
    204208unit_t *configuration_find_unit_by_name(const char *name)
    205209{
    206         ht_link_t *ht_link = hash_table_find(&units, (void *)name);
     210        ht_link_t *ht_link = hash_table_find(&units_by_name, (void *)name);
    207211        if (ht_link != NULL) {
    208                 return hash_table_get_inst(ht_link, unit_t, units);
     212                return hash_table_get_inst(ht_link, unit_t, units_by_name);
    209213        } else {
    210214                return NULL;
Note: See TracChangeset for help on using the changeset viewer.