Module: xenomai-forge
Branch: next
Commit: fad1d413ea04d256f5e7fada4c0790f86352f6ff
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=fad1d413ea04d256f5e7fada4c0790f86352f6ff

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed Feb 19 16:26:31 2014 +0100

cobalt/registry: drop unused support for safe removal

---

 include/cobalt/kernel/registry.h |    9 --
 kernel/cobalt/registry.c         |  217 --------------------------------------
 2 files changed, 226 deletions(-)

diff --git a/include/cobalt/kernel/registry.h b/include/cobalt/kernel/registry.h
index a5e814e..e3763c8 100644
--- a/include/cobalt/kernel/registry.h
+++ b/include/cobalt/kernel/registry.h
@@ -35,8 +35,6 @@ struct xnpnode;
 struct xnobject {
        void *objaddr;
        const char *key;          /* !< Hash key. May be NULL if anonynous. */
-       struct xnsynch safesynch; /* !< Safe synchronization object. */
-       unsigned long safelock;   /* !< Safe lock count. */
        unsigned long cstamp;             /* !< Creation stamp. */
 #ifdef CONFIG_XENO_OPT_VFILE
        struct xnpnode *pnode;  /* !< v-file information class. */
@@ -181,18 +179,11 @@ int xnregistry_bind(const char *key,
 
 int xnregistry_remove(xnhandle_t handle);
 
-int xnregistry_remove_safe(xnhandle_t handle,
-                          xnticks_t timeout);
-
-void *xnregistry_get(xnhandle_t handle);
-
 void *xnregistry_fetch(xnhandle_t handle);
 
 void *xnregistry_lookup(xnhandle_t handle,
                        unsigned long *cstamp_r);
 
-unsigned long xnregistry_put(xnhandle_t handle);
-
 int xnregistry_unlink(const char *key);
 
 unsigned xnregistry_hash_size(void);
diff --git a/kernel/cobalt/registry.c b/kernel/cobalt/registry.c
index 21938b6..02b0cc3 100644
--- a/kernel/cobalt/registry.c
+++ b/kernel/cobalt/registry.c
@@ -639,10 +639,8 @@ int xnregistry_enter(const char *key, void *objaddr,
 
        object = list_get_entry(&free_object_list, struct xnobject, link);
        nr_active_objects++;
-       xnsynch_init(&object->safesynch, XNSYNCH_FIFO, NULL);
        object->objaddr = objaddr;
        object->cstamp = ++next_object_stamp;
-       object->safelock = 0;
 #ifdef CONFIG_XENO_OPT_VFILE
        object->pnode = NULL;
 #endif
@@ -899,221 +897,6 @@ unlock_and_exit:
        return ret;
 }
 
-/**
- * @fn int xnregistry_remove_safe(xnhandle_t handle,xnticks_t timeout)
- * @brief Unregister an idle real-time object.
- *
- * This service removes an object from the registry. The caller might
- * sleep as a result of waiting for the target object to be unlocked
- * prior to the removal (see xnregistry_put()).
- *
- * @param handle The generic handle of the object to remove.
- *
- * @param timeout If the object is locked on entry, @a param gives the
- * number of nanoseconds to wait for the unlocking to occur.  Passing
- * XN_INFINITE causes the caller to block indefinitely until the
- * object is unlocked. Passing XN_NONBLOCK causes the service to
- * return immediately without waiting if the object is locked on
- * entry.
- *
- * @return 0 is returned upon success. Otherwise:
- *
- * - -ESRCH is returned if @a handle does not reference a registered
- * object.
- *
- * - -EWOULDBLOCK is returned if @a timeout is equal to XN_NONBLOCK
- * and the object is locked on entry.
- *
- * - -EBUSY is returned if @a handle refers to a locked object and the
- * caller could not sleep until it is unlocked.
- *
- * - -ETIMEDOUT is returned if the object cannot be removed within the
- * specified amount of time.
- *
- * - -EINTR is returned if xnthread_unblock() has been called for the
- * calling thread waiting for the object to be unlocked.
- *
- * @remark Tags: primary-only, might-switch.
- */
-
-int xnregistry_remove_safe(xnhandle_t handle, xnticks_t timeout)
-{
-       unsigned long long cstamp;
-       struct xnobject *object;
-       int ret = 0, info;
-       spl_t s;
-
-       xnlock_get_irqsave(&nklock, s);
-
-       object = xnregistry_validate(handle);
-       if (object == NULL) {
-               ret = -ESRCH;
-               goto unlock_and_exit;
-       }
-
-       if (object->safelock == 0)
-               goto remove;
-
-       if (timeout == XN_NONBLOCK) {
-               ret = -EWOULDBLOCK;
-               goto unlock_and_exit;
-       }
-
-       if (xnsched_unblockable_p()) {
-               ret = -EBUSY;
-               goto unlock_and_exit;
-       }
-
-       /*
-        * The object creation stamp is here to deal with situations like this
-        * one:
-        *
-        * Thread(A) locks Object(T) using xnregistry_get()
-        * Thread(B) attempts to remove Object(T) using xnregistry_remove()
-        * Thread(C) attempts the same removal, waiting like Thread(B) for
-        * the object's safe count to fall down to zero.
-        * Thread(A) unlocks Object(T), unblocking Thread(B) and (C).
-        * Thread(B) wakes up and successfully removes Object(T)
-        * Thread(D) preempts Thread(C) and recycles Object(T) for another 
object
-        * Thread(C) wakes up and attempts to finalize the removal of the
-        * _former_ Object(T), which leads to the spurious removal of the
-        * _new_ Object(T).
-        */
-
-       cstamp = object->cstamp;
-
-       do {
-               info = xnsynch_sleep_on(&object->safesynch, timeout, 
XN_RELATIVE);
-               if (info & XNBREAK) {
-                       ret = -EINTR;
-                       goto unlock_and_exit;
-               }
-               if (info & XNTIMEO) {
-                       ret = -ETIMEDOUT;
-                       goto unlock_and_exit;
-               }
-       }
-       while (object->safelock > 0);
-
-       if (object->cstamp != cstamp) {
-               /* The caller should silently abort the removal process. */
-               ret = -ESRCH;
-               goto unlock_and_exit;
-       }
-
-remove:
-       ret = xnregistry_remove(handle);
-
-unlock_and_exit:
-       xnlock_put_irqrestore(&nklock, s);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(xnregistry_remove_safe);
-
-/**
- * @fn void *xnregistry_get(xnhandle_t handle)
- * @brief Find and lock a real-time object into the registry.
- *
- * This service retrieves an object from its handle into the registry
- * and prevents it removal atomically. A locking count is tracked, so
- * that xnregistry_get() and xnregistry_put() must be used in pair.
- *
- * @param handle The generic handle of the object to find and lock. If
- * XNOBJECT_SELF is passed, the object is the calling Xenomai
- * thread.
- *
- * @return The memory address of the object's descriptor is returned
- * on success. Otherwise, NULL is returned if @a handle does not
- * reference a registered object, or if @a handle is equal to
- * XNOBJECT_SELF but the current context is not a real-time thread.
- *
- * @remark Tags: isr-allowed.
- */
-
-void *xnregistry_get(xnhandle_t handle)
-{
-       struct xnobject *object;
-       void *objaddr;
-       spl_t s;
-
-       if (handle == XNOBJECT_SELF) {
-               if (!xnsched_primary_p())
-                       return NULL;
-               handle = xnsched_current_thread()->registry.handle;
-       }
-
-       xnlock_get_irqsave(&nklock, s);
-
-       object = xnregistry_validate(handle);
-       if (likely(object != NULL)) {
-               ++object->safelock;
-               objaddr = object->objaddr;
-       } else
-               objaddr = NULL;
-
-       xnlock_put_irqrestore(&nklock, s);
-
-       return objaddr;
-}
-EXPORT_SYMBOL_GPL(xnregistry_get);
-
-/**
- * @fn unsigned long xnregistry_put(xnhandle_t handle)
- * @brief Unlock a real-time object from the registry.
- *
- * This service decrements the lock count of a registered object
- * previously locked by a call to xnregistry_get(). The object is
- * actually unlocked from the registry when the locking count falls
- * down to zero, thus waking up any thread currently blocked on
- * xnregistry_remove() for unregistering it.
- *
- * @param handle The generic handle of the object to unlock. If
- * XNOBJECT_SELF is passed, the object is the calling Xenomai thread.
- *
- * @return The decremented lock count is returned upon success. Zero
- * is also returned if @a handle does not reference a registered
- * object, or if @a handle is equal to XNOBJECT_SELF but the current
- * context is not a real-time thread.
- *
- * @remark Tags: isr-allowed, might-switch.
- */
-
-unsigned long xnregistry_put(xnhandle_t handle)
-{
-       struct xnobject *object;
-       unsigned long newlock;
-       spl_t s;
-
-       if (handle == XNOBJECT_SELF) {
-               if (!xnsched_primary_p())
-                       return 0;
-               handle = xnsched_current_thread()->registry.handle;
-       }
-
-       xnlock_get_irqsave(&nklock, s);
-
-       object = xnregistry_validate(handle);
-       if (object == NULL) {
-               newlock = 0;
-               goto unlock_and_exit;
-       }
-
-       if ((newlock = object->safelock) > 0 &&
-           (newlock = --object->safelock) == 0 &&
-           xnsynch_pended_p(&object->safesynch)) {
-               xnsynch_flush(&object->safesynch, 0);
-               xnsched_run();
-       }
-
-      unlock_and_exit:
-
-       xnlock_put_irqrestore(&nklock, s);
-
-       return newlock;
-}
-EXPORT_SYMBOL_GPL(xnregistry_put);
-
 void *xnregistry_lookup(xnhandle_t handle,
                        unsigned long *cstamp_r)
 {


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to