No need to add anonymous registry entries with pseudo names to the hash table - no one will look them up anyway. Reduces hash key collisions for named objects.
--- ChangeLog | 3 +++ ksrc/nucleus/registry.c | 34 ++++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) Index: b/ksrc/nucleus/registry.c =================================================================== --- a/ksrc/nucleus/registry.c +++ b/ksrc/nucleus/registry.c @@ -542,7 +542,9 @@ static inline unsigned registry_wakeup_s * @param key A valid NULL-terminated string by which the object will * be indexed and later retrieved in the registry. Since it is assumed * that such key is stored into the registered object, it will *not* - * be copied but only kept by reference in the registry. + * be copied but only kept by reference in the registry. Pass an empty + * string if the object shall only occupy a registry slot + * for handle-based lookups. * * @param objaddr An opaque pointer to the object to index by @a * key. @@ -560,8 +562,8 @@ static inline unsigned registry_wakeup_s * * @return 0 is returned upon success. Otherwise: * - * - -EINVAL is returned if @a key or @a objaddr are NULL, or if @a - * key constains an invalid '/' character. + * - -EINVAL is returned if @a objaddr are NULL, or if @a key constains + * an invalid '/' character. * * - -ENOMEM is returned if the system fails to get enough dynamic * memory from the global real-time heap in order to register the @@ -601,6 +603,18 @@ int xnregistry_enter(const char *key, object = link2xnobj(holder); + xnsynch_init(&object->safesynch, XNSYNCH_FIFO); + object->objaddr = objaddr; + object->cstamp = ++registry_obj_stamp; + object->safelock = 0; + object->pnode = NULL; + + if (!*key) { + object->key = NULL; + *phandle = object - registry_obj_slots; + return 0; + } + err = registry_hash_enter(key, object); if (err) { @@ -608,10 +622,6 @@ int xnregistry_enter(const char *key, goto unlock_and_exit; } - xnsynch_init(&object->safesynch, XNSYNCH_FIFO); - object->objaddr = objaddr; - object->cstamp = ++registry_obj_stamp; - object->safelock = 0; appendq(®istry_obj_busyq, holder); /* <!> Make sure the handle is written back before the @@ -621,10 +631,6 @@ int xnregistry_enter(const char *key, #ifdef CONFIG_XENO_EXPORT_REGISTRY if (pnode) registry_proc_export(object, pnode); - else { - object->proc = NULL; - object->pnode = NULL; - } #endif /* CONFIG_XENO_EXPORT_REGISTRY */ if (registry_wakeup_sleepers(key)) @@ -831,10 +837,14 @@ int xnregistry_remove(xnhandle_t handle) object->pnode->type); #endif - registry_hash_remove(object); object->objaddr = NULL; object->cstamp = 0; + if (!object->key) + goto unlock_and_exit; + + registry_hash_remove(object); + #ifdef CONFIG_XENO_EXPORT_REGISTRY if (object->pnode) { registry_proc_unexport(object); Index: b/ChangeLog =================================================================== --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-08-26 Jan Kiszka <[EMAIL PROTECTED]> + * ksrc/nucleus/registry.c (xnregistry_enter/remove): Allow for + key-less anonymous object registration. + * ksrc/nucleus/registry.c (xnregistry_fetch/get/put): Remove pointless locking, move XNOBJECT_SELF lookups out of critical sections. _______________________________________________ Xenomai-core mailing list Xenomai-core@gna.org https://mail.gna.org/listinfo/xenomai-core