]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/rm-lld.git/blobdiff - src/rm.c
tree.h cache-instrumented macros were invalidating NULL pointers in some cases
[keystone-rtos/rm-lld.git] / src / rm.c
index f805f8cd359d46b75dce09cc67f2e7c2b120ae60..d95d87eca17d4eeb22025b3032c2f57351cbafa5 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -6,7 +6,7 @@
  *
  *  \par
  *  ============================================================================
- *  @n   (C) Copyright 2012-2013, Texas Instruments, Inc.
+ *  @n   (C) Copyright 2012-2015, Texas Instruments, Inc.
  * 
  *  Redistribution and use in source and binary forms, with or without 
  *  modification, are permitted provided that the following conditions 
@@ -41,7 +41,6 @@
 
 /* Standard includes */
 #include <stdint.h>
-#include <string.h>
 
 /* RM external includes */
 #include <ti/drv/rm/rm.h>
@@ -98,8 +97,8 @@ static uint32_t transactionGetSequenceNum(Rm_Inst *rmInst)
     rmInst->transactionSeqNum++;
     if (!rmInst->transactionSeqNum) {
         rmInst->transactionSeqNum++;
-    }    
-    return (rmInst->transactionSeqNum);
+    }
+    return(rmInst->transactionSeqNum);
 }
 
 /* FUNCTION PURPOSE: Creates a resource request packet
@@ -110,29 +109,36 @@ static uint32_t transactionGetSequenceNum(Rm_Inst *rmInst)
  *              is allocated via the rmAllocPkt API using the
  *              appTransport handle provided by the application
  */
-void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *transaction)
+static Rm_Packet *createResourceReqPkt(Rm_ResourceReqPktType resReqType,
+                                       Rm_Transport *dstTrans,
+                                       const char *locInstName,
+                                       Rm_Transaction *transaction,
+                                       Rm_PacketHandle *pktHandle)
 {
+    Rm_Packet             *rmPkt = NULL;
     Rm_ResourceRequestPkt *resourceReqPkt = NULL;
-       
+
+    rmPkt = dstTrans->callouts.rmAllocPkt(dstTrans->appTransportHandle,
+                                          sizeof(Rm_Packet), pktHandle);
+    if ((rmPkt == NULL) || (pktHandle == NULL)) {
+        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+        goto errorExit;
+    }
+
     rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;
     resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;
-    resourceReqPkt->requestId = transaction->localId;
-    if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_INIT;
-    }
-    else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;
-    }    
-    else if (transaction->type == Rm_service_RESOURCE_FREE) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;
-    }
-    else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;
-    }
-    strncpy(resourceReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
-    strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
-    memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
-            sizeof(Rm_ResourceInfo));
+    resourceReqPkt->requestId       = transaction->localId;
+    resourceReqPkt->resourceReqType = resReqType;
+    rm_strncpy(resourceReqPkt->pktSrcInstName, locInstName,
+               RM_NAME_MAX_CHARS);
+    rm_strncpy(resourceReqPkt->serviceSrcInstName,
+               transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
+    memcpy((void *)&(resourceReqPkt->resourceInfo),
+           (void *)&(transaction->resourceInfo),
+           sizeof(Rm_ResourceInfo));
+
+errorExit:
+    return(rmPkt);
 }
 
 /* FUNCTION PURPOSE: Creates a resource response packet
@@ -143,16 +149,18 @@ void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction
  *              is allocated via the rmAllocPkt API using the
  *              appTransport handle provided by the application
  */
-void createResourceResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
+static void createResourceResponsePkt(Rm_Packet *rmPkt,
+                                      Rm_Transaction *transaction)
 {
     Rm_ResourceResponsePkt *resourceRespPkt = NULL;
-     
-    rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;                 
+
+    rmPkt->pktType = Rm_pktType_RESOURCE_RESPONSE;
     resourceRespPkt = (Rm_ResourceResponsePkt *)rmPkt->data;
     resourceRespPkt->responseId = transaction->remoteOriginatingId;
     resourceRespPkt->requestState = transaction->state;
-    memcpy ((void *)&(resourceRespPkt->resourceInfo), (void *)&(transaction->resourceInfo),
-            sizeof(Rm_ResourceInfo));
+    memcpy((void *)&(resourceRespPkt->resourceInfo),
+           (void *)&(transaction->resourceInfo),
+           sizeof(Rm_ResourceInfo));
 }
 
 /* FUNCTION PURPOSE: Creates a NameServer request packet
@@ -163,23 +171,36 @@ void createResourceResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
  *              is allocated via the rmAllocPkt API using the
  *              appTransport handle provided by the application
  */
-void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *transaction)
-{ 
+static Rm_Packet *createNsRequestPkt(Rm_NsReqPktType nsReqType,
+                                     Rm_Transport *dstTrans,
+                                     const char *locInstName,
+                                     Rm_Transaction *transaction,
+                                     Rm_PacketHandle *pktHandle)
+{
+    Rm_Packet       *rmPkt = NULL;
     Rm_NsRequestPkt *nsReqPkt = NULL;
 
-    rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;                   
-    nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;
-    nsReqPkt->requestId = transaction->localId;
-    if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
-        nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;
-    }
-    else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
-        nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;
+
+    rmPkt = dstTrans->callouts.rmAllocPkt(dstTrans->appTransportHandle,
+                                          sizeof(Rm_Packet), pktHandle);
+    if ((rmPkt == NULL) || (pktHandle == NULL)) {
+        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+        goto errorExit;
     }
-    strncpy(nsReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
-    strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
-    memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
-            sizeof(Rm_ResourceInfo));
+
+    rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;
+    nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;
+    nsReqPkt->requestId     = transaction->localId;
+    nsReqPkt->nsRequestType = nsReqType;
+    rm_strncpy(nsReqPkt->pktSrcInstName, locInstName, RM_NAME_MAX_CHARS);
+    rm_strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName,
+               RM_NAME_MAX_CHARS);
+    memcpy((void *)&(nsReqPkt->resourceInfo),
+           (void *)&(transaction->resourceInfo),
+           sizeof(Rm_ResourceInfo));
+
+errorExit:
+    return(rmPkt);
 }
 
 /* FUNCTION PURPOSE: Creates a NameServer response packet
@@ -190,16 +211,72 @@ void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *t
  *              is allocated via the rmAllocPkt API using the
  *              appTransport handle provided by the application
  */
-void createNsResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
+static void createNsResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
 {
     Rm_NsResponsePkt *nsRespPkt = NULL;
 
-    rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;                
+    rmPkt->pktType = Rm_pktType_NAMESERVER_RESPONSE;
     nsRespPkt = (Rm_NsResponsePkt *)rmPkt->data;
     nsRespPkt->responseId = transaction->remoteOriginatingId;
     nsRespPkt->requestState = transaction->state;
 }
 
+/* FUNCTION PURPOSE: Creates a request packet
+ ***********************************************************************
+ * DESCRIPTION: Returns a RM packet handle that points to a request packet.
+ *              The request packet type is based on the transaction type.
+ */
+static Rm_Packet *createRequestPkt(Rm_Transport *dstTrans,
+                                   const char *locInstName,
+                                   Rm_Transaction *transaction,
+                                   Rm_PacketHandle *pktHandle)
+{
+    Rm_Packet *rmPkt = NULL;
+
+    switch (transaction->type) {
+        case Rm_service_RESOURCE_ALLOCATE_INIT:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_ALLOCATE_INIT,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_ALLOCATE_USE:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_ALLOCATE_USE,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_STATUS:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_GET_STATUS,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_FREE:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_FREE,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_GET_BY_NAME:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_GET_NAMED,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_MAP_TO_NAME:
+            rmPkt = createNsRequestPkt(Rm_nsReqPktType_MAP_RESOURCE,
+                                       dstTrans, locInstName, transaction,
+                                       pktHandle);
+            break;
+        case Rm_service_RESOURCE_UNMAP_NAME:
+            rmPkt = createNsRequestPkt(Rm_nsReqPktType_UNMAP_RESOURCE,
+                                       dstTrans, locInstName, transaction,
+                                       pktHandle);
+            break;
+        default:
+            transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
+            break;
+    }
+
+    return(rmPkt);
+}
+
 /* FUNCTION PURPOSE: Issues a service response to application
  ***********************************************************************
  * DESCRIPTION: Provides a service response back to the application
@@ -217,29 +294,35 @@ static void serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
     /* Pass back the ID that was provided to the component when it requested
      * the service */
     serviceResponse.serviceId = transaction->localId;
+    /* Owner and instance allocation count will only be set within RM under
+     * certain circumstances. */
+    serviceResponse.resourceNumOwners = transaction->resourceInfo.ownerCount;
+    serviceResponse.instAllocCount = transaction->resourceInfo.instAllocCount;
 
     /* Service was approved and service was an allocate request.  The resource
      * data is passed back to the component */
     if ((serviceResponse.serviceState == RM_SERVICE_APPROVED) &&
         ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
          (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
-         (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))
-    {
-        strncpy(serviceResponse.resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+         (transaction->type == Rm_service_RESOURCE_FREE) ||
+         (transaction->type == Rm_service_RESOURCE_STATUS) ||
+         (transaction->type == Rm_service_RESOURCE_GET_BY_NAME))) {
+        rm_strncpy(serviceResponse.resourceName, transaction->resourceInfo.name,
+                   RM_NAME_MAX_CHARS);
         serviceResponse.resourceBase = transaction->resourceInfo.base;
         serviceResponse.resourceLength = transaction->resourceInfo.length;
     }
 
-    if (transaction->callback.serviceCallback) {
-        /* Issue the callback to the requesting component with the response information */
-        transaction->callback.serviceCallback(&serviceResponse);
+    if (transaction->u.callback.serviceCallback) {
+        /* Issue the callback to the requesting component with the response
+         * information */
+        transaction->u.callback.serviceCallback(&serviceResponse);
         /* Delete the transaction from the transaction queue */
         rmTransactionQueueDelete(rmInst, transaction->localId);
-    }
-    else {
+    } else {
         rmServiceInternalCallback((Rm_Handle)rmInst);
     }
-    
+
     return;
 }
 
@@ -252,44 +335,45 @@ static void serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
  */
 static void transactionResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
-    Rm_Transport    *dstTransport = NULL;
+    Rm_Transport    *dstTransport = transaction->u.respTrans;
     Rm_Packet       *rmPkt = NULL;
     Rm_PacketHandle  pktHandle = NULL;
 
-    if (dstTransport = rmTransportFindRemoteName(rmInst->transports, transaction->pktSrcInstName)) {
-        rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle, 
-                                                  sizeof(Rm_Packet), &pktHandle);
-        if (!rmPkt || !pktHandle) {
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
-            goto errorExit;
-        }
+    rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle,
+                                              sizeof(Rm_Packet), &pktHandle);
+    if (!rmPkt || !pktHandle) {
+        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+        goto errorExit;
+    }
 
-        switch (transaction->type) {
-            case Rm_service_RESOURCE_ALLOCATE_INIT:
-            case Rm_service_RESOURCE_ALLOCATE_USE:
-            case Rm_service_RESOURCE_FREE:
-            case Rm_service_RESOURCE_GET_BY_NAME:
-                createResourceResponsePkt(rmPkt, transaction);
-                break;
-            case Rm_service_RESOURCE_MAP_TO_NAME:
-            case Rm_service_RESOURCE_UNMAP_NAME:
-                createNsResponsePkt(rmPkt, transaction);
-                break;
-        }
-        if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
-            transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
+    switch (transaction->type) {
+        case Rm_service_RESOURCE_ALLOCATE_INIT:
+        case Rm_service_RESOURCE_ALLOCATE_USE:
+        case Rm_service_RESOURCE_STATUS:
+        case Rm_service_RESOURCE_FREE:
+        case Rm_service_RESOURCE_GET_BY_NAME:
+            createResourceResponsePkt(rmPkt, transaction);
+            break;
+        case Rm_service_RESOURCE_MAP_TO_NAME:
+        case Rm_service_RESOURCE_UNMAP_NAME:
+            createNsResponsePkt(rmPkt, transaction);
+            break;
+        default:
+            transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
             goto errorExit;
-        }
-        
-        /* Response packet sent: Delete transaction from queue */
-        rmTransactionQueueDelete(rmInst, transaction->localId);
     }
-    else {
-        transaction->state = RM_ERROR_TRANSPORT_REMOTE_HNDL_NOT_REGD;
+    if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle,
+                                         pktHandle) < RM_OK) {
+        transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
+        goto errorExit;
     }
+
+    /* Response packet sent: Delete transaction from queue */
+    rmTransactionQueueDelete(rmInst, transaction->localId);
+
 errorExit:
-    /* Do not delete transaction on error.  Error transactions should be visible from
-     * from Rm_printInstanceStatus() */
+    /* Do not delete transaction on transport error.  Transport error
+     * transactions should be visible from Rm_printInstanceStatus() */
     return;
 }
 
@@ -300,53 +384,51 @@ errorExit:
  *              The request is sent via the RM transport API which is
  *              plugged with an application created transport path.
  */
-static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void transactionForwarder(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
-    Rm_Transport    *dstTransport = NULL;
-    Rm_Packet       *rmPkt = NULL;    
-    Rm_PacketHandle  pktHandle = NULL;
+    Rm_Transport *dstTrans;
 
     if (rmInst->instType == Rm_instType_CLIENT) {
-        dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_CLIENT_DELEGATE);
-
-        if (!dstTransport) {
-            dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_SERVER);
+        dstTrans = rmTransportFindRemoteInstType(rmInst->transports,
+                                                 Rm_instType_CLIENT_DELEGATE);
+        if (dstTrans == NULL) {
+            dstTrans = rmTransportFindRemoteInstType(rmInst->transports,
+                                                     Rm_instType_SERVER);
         }
-    } 
-    else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        dstTransport = rmTransportFindRemoteInstType(rmInst->transports, Rm_instType_SERVER);
+    } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        dstTrans = rmTransportFindRemoteInstType(rmInst->transports,
+                                                 Rm_instType_SERVER);
+    } else {
+        dstTrans = NULL;
     }
 
-    /* Just queue transaction if transport hasn't been registered.  Do not return error */
-    if (dstTransport) {            
-        rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle, 
-                                                  sizeof(Rm_Packet), &pktHandle);
-        if (!rmPkt || !pktHandle) {
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+    /* Just queue transaction if transport hasn't been registered.  Do not
+     * return error */
+    if (dstTrans) {
+        Rm_Packet       *rmPkt = NULL;
+        Rm_PacketHandle  pktHandle = NULL;
+
+        rmPkt = createRequestPkt(dstTrans, rmInst->instName, transaction,
+                                 &pktHandle);
+        if ((rmPkt == NULL) || (pktHandle == NULL)) {
+            /* Error returned via transaction->state */
             goto errorExit;
         }
 
-        switch (transaction->type) {
-            case Rm_service_RESOURCE_ALLOCATE_INIT:
-            case Rm_service_RESOURCE_ALLOCATE_USE:
-            case Rm_service_RESOURCE_FREE:
-            case Rm_service_RESOURCE_GET_BY_NAME:
-                createResourceReqPkt(rmPkt, rmInst->instName, transaction);
-                break;
-            case Rm_service_RESOURCE_MAP_TO_NAME:
-            case Rm_service_RESOURCE_UNMAP_NAME:
-                createNsRequestPkt(rmPkt, rmInst->instName, transaction);
-                break;
-        }
-  
-        if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle, pktHandle) < RM_OK) {
+        if (dstTrans->callouts.rmSendPkt(dstTrans->appTransportHandle,
+                                         pktHandle) < RM_OK) {
             transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
             goto errorExit;
-        }              
+        }
         transaction->hasBeenForwarded = RM_TRUE;
-        /* Transaction not deleted.  Waiting for response from RM CD or Server */
-    }        
-errorExit: 
+        /* Transaction not deleted.  Waiting for response from RM CD or
+         * Server */
+    } else {
+        transaction->state = RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST;
+    }
+errorExit:
+    /* Do not delete transaction on transport error.  Transport error
+     * transactions should be visible from Rm_printInstanceStatus() */
     return;
 }
 
@@ -357,45 +439,143 @@ errorExit:
  *              with a Server.  The allocation request is validated
  *              against a static policy.
  */
-static void staticAllocationHandler (Rm_StaticAllocCfg *staticAllocCfg, Rm_Transaction *transaction)
+static void staticAllocationHandler(Rm_Handle rmHandle,
+                                    Rm_Transaction *transaction)
 {
-    Rm_PolicyCheckCfg       privCheckCfg;
-    
-    if (staticAllocCfg->staticPolicy) {
-        if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
-            (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
-            /* Check request against startup policy */
+    Rm_Inst           *rmInst = (Rm_Inst *)rmHandle;
+    Rm_AllocatorNode  *allocNode = NULL;
+    Rm_PolicyCheckCfg  privCheckCfg;
+
+    if (rmInst->allocatorTree) {
+        allocNode = rmAllocatorFind(rmHandle, transaction->resourceInfo.name);
+
+        if (allocNode &&
+            ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+             (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE))) {
+            /* Check request against static policy */
             memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));
-    
+
             if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
                 privCheckCfg.type = Rm_policyCheck_INIT;
-            }
-            else {
+            } else {
                 privCheckCfg.type = Rm_policyCheck_USE;
             }
-            privCheckCfg.policyDtb = staticAllocCfg->staticPolicy;
-            privCheckCfg.validInstNode = rmPolicyGetValidInstNode(staticAllocCfg->staticValidInstTree, 
-                                                                  staticAllocCfg->instName);
-            privCheckCfg.resourceOffset = rmPolicyGetResourceOffset(staticAllocCfg->staticPolicy,
-                                                                    transaction->resourceInfo.name);
-            privCheckCfg.resourceBase = transaction->resourceInfo.base;
+            privCheckCfg.negCheck       = RM_FALSE;
+            privCheckCfg.validInstNode  = rmPolicyGetValidInstNode(rmHandle,
+                                                              rmInst->instName);
+            privCheckCfg.polTree        = allocNode->policyRoot;
+            privCheckCfg.resourceBase   = transaction->resourceInfo.base;
             privCheckCfg.resourceLength = transaction->resourceInfo.length;
-    
-            if (rmPolicyCheckPrivilege(&privCheckCfg, &transaction->state)) {
+
+            if (rmPolicyCheckPrivilege(&privCheckCfg)) {
                 transaction->state = RM_SERVICE_APPROVED_STATIC;
-            }
-            else if (transaction->state == RM_SERVICE_PROCESSING) {
-                /* Privilege check returned false without error */
+            } else {
                 transaction->state = RM_SERVICE_DENIED_BY_STATIC_POLICY;
             }
-        }
-        else {
+        } else {
             transaction->state = RM_SERVICE_DENIED_INVALID_STATIC_REQUEST;
         }
-    }
-    else {
+    } else {
         transaction->state = RM_ERROR_REQ_FAILED_NO_STATIC_POLICY;
-    } 
+    }
+}
+
+/* FUNCTION PURPOSE: Requests resources from Server for CD
+ ***********************************************************************
+ * DESCRIPTION: Function creates a service request to allocate resources
+ *              from the Server for local management by the CD.  The
+ *              transaction which causes this request is put in the
+ *              pending state in order to wait for the response from the 
+ *              Server
+ */
+static int32_t cdRequestServerResources(Rm_Inst *rmInst,
+                                        Rm_Transaction *transaction)
+{
+    Rm_AllocatorNode *allocNode = NULL;
+    Rm_Transaction   *newTrans = NULL;
+    uint32_t          allocSize = 0;
+    int32_t           retVal;
+
+    allocNode = rmAllocatorFind((Rm_Handle)rmInst,
+                                transaction->resourceInfo.name);
+
+    if (allocNode) {
+        if ((allocSize = rmPolicyGetCdAllocSize(allocNode->policyRoot))) {
+            if ((newTrans = rmTransactionQueueAdd(rmInst))) {
+                newTrans->type = transaction->type;
+                rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName,
+                           RM_NAME_MAX_CHARS);
+                newTrans->state = RM_SERVICE_PROCESSING;
+                rm_strncpy(newTrans->resourceInfo.name,
+                           transaction->resourceInfo.name,
+                           RM_NAME_MAX_CHARS);
+                newTrans->resourceInfo.base = RM_RESOURCE_BASE_UNSPECIFIED;
+                /* Make sure request length will satisfy transaction length */
+                newTrans->resourceInfo.length = allocSize;
+                while (newTrans->resourceInfo.length <
+                       transaction->resourceInfo.length) {
+                    newTrans->resourceInfo.length += allocSize;
+                }
+                newTrans->resourceInfo.alignment = transaction->resourceInfo.alignment;
+                newTrans->pendingTransactionId = transaction->localId;
+                transactionForwarder(rmInst, newTrans);
+
+                retVal = RM_SERVICE_PENDING_SERVER_RESPONSE;
+            } else {
+                retVal = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
+            }
+        } else {
+            /* Forward request to Server for completion if policy has 
+             * no allocation size for resource */
+            retVal = RM_SERVICE_PROCESSING;
+        }
+    } else {
+        /* Resource could not be found in policy */
+        retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;
+    }
+    return(retVal);
+}
+
+/* FUNCTION PURPOSE: Frees local resources to Server from CD
+ ***********************************************************************
+ * DESCRIPTION: Function creates a service request to free locally
+ *              managed resources that are now localized back to
+ *              the Server.
+ */
+static int32_t cdFreeResourcesToServer(Rm_Inst *rmInst,
+                                       Rm_Transaction *transaction)
+{
+    int32_t         baseToFree = transaction->resourceInfo.base;
+    uint32_t        lenToFree = transaction->resourceInfo.length;
+    Rm_Transaction *newTrans = NULL; 
+    /* This function should only be called after a free was approved */
+    int32_t         retVal = RM_SERVICE_APPROVED;    
+
+    /* Did free result in a localized free node that can be given back to
+     * Server?  If so create transaction to Server to free localized
+     * resource node */
+    if (rmAllocatorGetNodeLocalization((Rm_Handle)rmInst,
+                                       transaction->resourceInfo.name,
+                                       &baseToFree, &lenToFree)) {
+        if ((newTrans = rmTransactionQueueAdd(rmInst))) {
+            newTrans->type = transaction->type;
+            rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName,
+                       RM_NAME_MAX_CHARS);
+            newTrans->state = RM_SERVICE_PROCESSING;
+            rm_strncpy(newTrans->resourceInfo.name,
+                       transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+            newTrans->resourceInfo.base = baseToFree;
+            newTrans->resourceInfo.length = lenToFree;
+            newTrans->pendingTransactionId = transaction->localId;
+            transactionForwarder(rmInst, newTrans);
+
+            retVal = RM_SERVICE_PENDING_SERVER_RESPONSE;
+        } else {
+            /* Error: Need to re-allocate what was freed */
+            retVal = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
+        }
+    }
+    return(retVal);
 }
 
 /* FUNCTION PURPOSE: Arbitrates allocation service requests
@@ -410,70 +590,223 @@ static void staticAllocationHandler (Rm_StaticAllocCfg *staticAllocCfg, Rm_Trans
  */
 static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
-    Rm_AllocatorOpInfo  opInfo;
-    
-    Rm_NameServerObjCfg nameServerObjCfg;
-    int32_t             retVal = transaction->state;
+    Rm_AllocatorOpInfo   opInfo;
+    Rm_NameServerObjCfg  nameServerObjCfg;
+    int32_t              retVal = transaction->state;
+
+    memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+    opInfo.resourceInfo = &transaction->resourceInfo;
+    opInfo.serviceInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
+                                              transaction->serviceSrcInstName);
+    if (opInfo.serviceInstNode == NULL) {
+        retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+        goto errorExit;
+    }
 
     if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        transactionForwarder(rmInst, transaction);   
-    }
-    else if (rmInst->instType == Rm_instType_SERVER) {
-        memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
-        
-        opInfo.policy = rmInst->u.server.globalPolicy;
-        opInfo.resourceInfo = &transaction->resourceInfo;
-        opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->u.server.globalValidInstTree, transaction->serviceSrcInstName);
-        if (opInfo.serviceSrcInstNode) {
-            switch (transaction->type) {
-                case Rm_service_RESOURCE_ALLOCATE_INIT:
-                    RM_policy_SET_PERM(opInfo.allocType, RM_POLICY_PERM_INIT_SHIFT, 1);
-                    break;
-                case Rm_service_RESOURCE_ALLOCATE_USE:
-                    RM_policy_SET_PERM(opInfo.allocType, RM_POLICY_PERM_USE_SHIFT, 1);    
-                    break;
-            }        
-
-            /* Populated NameServer name has precedence over base */
-            if (strlen(transaction->resourceInfo.nameServerName) > 0) {
-                if ((transaction->resourceInfo.base == 0) &&
-                    (transaction->resourceInfo.length == 0) &&
-                    (transaction->resourceInfo.alignment == 0)) {
-                    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
-                        rmNameServerTreeInv(rmInst->u.server.nameServer);
-                    }
-                    memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
-                    nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
-                    nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
-                    if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
-                        strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
-                        transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
-                        transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
-                    }                
+        if (transaction->resourceInfo.base != RM_RESOURCE_BASE_UNSPECIFIED) {
+            if (rmAllocatorFind((Rm_Handle)rmInst,
+                                transaction->resourceInfo.name)) {
+                /* Attempt to allocate from local resources that were provided
+                 * by Server */
+                if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+                    opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
+                } else if (transaction->type ==
+                           Rm_service_RESOURCE_ALLOCATE_USE) {
+                    opInfo.operation = Rm_allocatorOp_ALLOCATE_USE;
+                } else {
+                    retVal = RM_ERROR_INVALID_SERVICE_TYPE;
+                    goto errorExit;
                 }
-                else {
-                    retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
+                retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+
+                if (retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) {
+                    /* Request resource range was not found within local
+                     * resources provided by Server.  Set back to PROCESSING so
+                     * request is forwarded to Server */
+                    retVal = RM_SERVICE_PROCESSING;
                 }
             }
-
-            if (retVal == RM_SERVICE_PROCESSING) {      
-                if (transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) {
-                    opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE;
-                    retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+        } else {
+            if (rmAllocatorFind((Rm_Handle)rmInst,
+                                transaction->resourceInfo.name)) {
+                int32_t oldAlign = transaction->resourceInfo.alignment;
+
+                /* Attempt to allocate from local resources that were provided
+                 * by Server */
+                if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+                    opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_INIT;
+                } else if (transaction->type ==
+                         Rm_service_RESOURCE_ALLOCATE_USE) {
+                    opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_USE;
+                } else {
+                    retVal = RM_ERROR_INVALID_SERVICE_TYPE;
+                    goto errorExit;
                 }
-            
+                retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+
                 if (retVal == RM_SERVICE_PROCESSING) {
-                    opInfo.operation = Rm_allocatorOp_ALLOCATE;
+                    if (transaction->type ==
+                        Rm_service_RESOURCE_ALLOCATE_INIT) {
+                        opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
+                    } else if (transaction->type ==
+                               Rm_service_RESOURCE_ALLOCATE_USE) {
+                        opInfo.operation = Rm_allocatorOp_ALLOCATE_USE;
+                    } else {
+                        retVal = RM_ERROR_INVALID_SERVICE_TYPE;
+                        goto errorExit;
+                    }
                     retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
-                }      
+
+                    if (retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) {
+                        /* Request resource range was not found within local
+                         * resources provided by Server.  Set back to
+                         * PROCESSING so request is forwarded to Server */
+                        retVal = RM_SERVICE_PROCESSING;
+                    }
+                } else if (retVal == RM_SERVICE_DENIED_RES_ALLOC_REQS_NOT_MET) {
+                    if (transaction->pendingTransactionId) {
+                        /* Request to Server for resources to complete
+                         * transaction locally performed once already.  Forward
+                         * transaction to Server for completion */
+                        retVal = RM_SERVICE_PROCESSING;
+                    } else {
+                        /* Restore base and alignment since they were replaced
+                         * in pre-allocate routine */
+                        transaction->resourceInfo.base = RM_RESOURCE_BASE_UNSPECIFIED;
+                        transaction->resourceInfo.alignment = oldAlign;
+
+                        retVal = cdRequestServerResources(rmInst, transaction);
+                    }
+                }
+                /* else: fall through to return */
+            } else {
+                retVal = cdRequestServerResources(rmInst, transaction);
             }
         }
-        else {
-            retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+    } else if ((rmInst->instType == Rm_instType_SERVER)||
+               (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+        /* Populated NameServer name has precedence over base */
+        if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+            if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+                rmNameServerTreeInv(rmInst->u.server.nameServer);
+            }
+            memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+            nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
+            nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
+            if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) ==
+                RM_SERVICE_PROCESSING) {
+                rm_strncpy(transaction->resourceInfo.name,
+                           nameServerObjCfg.nodeCfg.resourceName,
+                           RM_NAME_MAX_CHARS);
+                transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+                transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+            } else {
+                goto errorExit;
+            }
         }
-        
-        transaction->state = retVal;                 
-    }   
+
+        if (transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) {
+            if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+                opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_INIT;
+            } else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+                opInfo.operation = Rm_allocatorOp_PRE_ALLOCATE_USE;
+            } else {
+                retVal = RM_ERROR_INVALID_SERVICE_TYPE;
+                goto errorExit;
+            }
+            retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+        }
+
+        if (retVal == RM_SERVICE_PROCESSING) {
+            if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
+                opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
+            } else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
+                opInfo.operation = Rm_allocatorOp_ALLOCATE_USE;
+            } else {
+                retVal = RM_ERROR_INVALID_SERVICE_TYPE;
+                goto errorExit;
+            }
+            retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+        }
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
+    }
+errorExit:
+    transaction->state = retVal;
+}
+
+/* FUNCTION PURPOSE: Handles resource status service requests
+ ***********************************************************************
+ * DESCRIPTION: Issues a set of allocator operations to retrieve the
+ *              current status (currently just owner reference count)
+ *              for the resource specified in the transaction
+ */
+static void statusHandler(Rm_Inst *rmInst, Rm_Transaction *transaction)
+{
+    Rm_AllocatorOpInfo  opInfo;
+    Rm_NameServerObjCfg nameServerObjCfg;
+    int32_t             retVal = transaction->state;
+
+    memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+    opInfo.operation = Rm_allocatorOp_GET_STATUS;
+    opInfo.resourceInfo = &transaction->resourceInfo;
+    opInfo.serviceInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
+                                            transaction->serviceSrcInstName);
+    if (opInfo.serviceInstNode == NULL) {
+        retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+        goto errorExit;
+    }
+
+    if ((strlen(transaction->resourceInfo.nameServerName) == 0) &&
+        ((transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) ||
+         (transaction->resourceInfo.length == 0))) {
+        retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;
+        goto errorExit;
+    }
+
+    if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        if (rmAllocatorFind((Rm_Handle)rmInst,
+                            transaction->resourceInfo.name)) {
+            /* Attempt to get status from local resources that were provided by
+             * Server */
+            retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+
+            if (retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) {
+                /* Request resource range was not found within local allocator
+                 * resources provided by Server.  Set back to PROCESSING so
+                 * request is forwarded to Server */
+                retVal = RM_SERVICE_PROCESSING;
+            }
+        }
+    } else if ((rmInst->instType == Rm_instType_SERVER)||
+               (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+        /* Populated NameServer name has precedence over base and length
+         * values */
+        if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+            if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+                rmNameServerTreeInv(rmInst->u.server.nameServer);
+            }
+            memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+            nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
+            nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
+            if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) ==
+                RM_SERVICE_PROCESSING) {
+                rm_strncpy(transaction->resourceInfo.name,
+                           nameServerObjCfg.nodeCfg.resourceName,
+                           RM_NAME_MAX_CHARS);
+                transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+                transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+            } else {
+                goto errorExit;
+            }
+        }
+        retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
+    }
+errorExit:
+    transaction->state = retVal;
 }
 
 /* FUNCTION PURPOSE: Arbitrates free service requests
@@ -486,55 +819,72 @@ static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
  *              retrieved from the NameServer prior to the free
  *              attempt.
  */
-static void freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void freeHandler(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
     Rm_AllocatorOpInfo  opInfo; 
-    Rm_NameServerObjCfg nameServerObjCfg;    
+    Rm_NameServerObjCfg nameServerObjCfg;
     int32_t             retVal = transaction->state;
-    
-    if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        transactionForwarder(rmInst, transaction);   
+
+    memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+    opInfo.operation = Rm_allocatorOp_FREE;
+    opInfo.resourceInfo = &transaction->resourceInfo;
+    opInfo.serviceInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
+                                            transaction->serviceSrcInstName);
+    if (opInfo.serviceInstNode == NULL) {
+        retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+        goto errorExit;
     }
-    else if (rmInst->instType == Rm_instType_SERVER) {
-        memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
-        
-        opInfo.policy = rmInst->u.server.globalPolicy;
-        opInfo.resourceInfo = &transaction->resourceInfo;
-        opInfo.serviceSrcInstNode = rmPolicyGetValidInstNode(rmInst->u.server.globalValidInstTree, transaction->serviceSrcInstName);
-        if (opInfo.serviceSrcInstNode) {
-            /* Populated NameServer name has precedence over base */
-            if (strlen(transaction->resourceInfo.nameServerName) > 0) {
-                if ((transaction->resourceInfo.base == 0) &&
-                    (transaction->resourceInfo.length == 0) &&
-                    (transaction->resourceInfo.alignment == 0)) {
-                    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
-                        rmNameServerTreeInv(rmInst->u.server.nameServer);
-                    }                    
-                    memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
-                    nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
-                    nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
-                    if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
-                        strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
-                        transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
-                        transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
-                    } 
-                }
-                else {
-                    retVal = RM_ERROR_NS_NAME_AND_RES_VAL_CONFLICT;
-                }                
-            }
-            
-            if(retVal == RM_SERVICE_PROCESSING) {        
-                opInfo.operation = Rm_allocatorOp_FREE;
-                retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
-            }    
+
+    if ((strlen(transaction->resourceInfo.nameServerName) == 0) &&
+        ((transaction->resourceInfo.base == RM_RESOURCE_BASE_UNSPECIFIED) ||
+         (transaction->resourceInfo.length == 0))) {
+        retVal = RM_SERVICE_DENIED_RES_DOES_NOT_EXIST;
+        goto errorExit;
+    }
+
+    if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        /* Attempt to free from local resources that were provided by Server */
+        retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+
+        if (retVal == RM_SERVICE_APPROVED) {
+            /* Check if free allows local resources to be freed back to
+             * Server */
+            retVal = cdFreeResourcesToServer(rmInst, transaction);
+        } else if ((retVal == RM_SERVICE_DENIED_RES_RANGE_DOES_NOT_EXIST) ||
+                 (retVal == RM_SERVICE_DENIED_RES_DOES_NOT_EXIST)) {
+            /* Requested resource or its range were not found within local
+             * allocator resources provided by Server.  Set back to PROCESSING
+             * so request is forwarded to Server */
+            retVal = RM_SERVICE_PROCESSING;
         }
-        else {
-            retVal = RM_SERVICE_DENIED_INST_NAME_NOT_VALID;
+        /* else: fall through to exit */
+    } else if ((rmInst->instType == Rm_instType_SERVER) ||
+             (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+        /* Populated NameServer name has precedence over base */
+        if (strlen(transaction->resourceInfo.nameServerName) > 0) {
+            if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+                rmNameServerTreeInv(rmInst->u.server.nameServer);
+            }                    
+            memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+            nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
+            nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
+            if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) ==
+                RM_SERVICE_PROCESSING) {
+                rm_strncpy(transaction->resourceInfo.name,
+                           nameServerObjCfg.nodeCfg.resourceName,
+                           RM_NAME_MAX_CHARS);
+                transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
+                transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
+            } else {
+                goto errorExit;
+            }
         }
-
-        transaction->state = retVal;       
-    }   
+        retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
+    }
+errorExit:
+    transaction->state = retVal;
 }
 
 /* FUNCTION PURPOSE: Client transaction handling process
@@ -547,35 +897,30 @@ static void freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
  *                  - Forwards all service requests to CD or Server
  *                    once transport has been registered
  */
-static void clientProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void clientProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
-    Rm_StaticAllocCfg  staticAllocCfg;
-    Rm_Transaction    *transQ = rmInst->transactionQueue;
-    
+    Rm_Transaction *transQ;
+
     if (!rmInst->registeredWithDelegateOrServer) {
-        staticAllocCfg.instName = rmInst->instName;
-        staticAllocCfg.staticPolicy = rmInst->u.client.staticPolicy;
-        staticAllocCfg.staticValidInstTree = rmInst->u.client.staticValidInstTree;
-        staticAllocationHandler(&staticAllocCfg, transaction);
-    }
-    else {
+        staticAllocationHandler((Rm_Handle)rmInst, transaction);
+    } else {
         if (transaction->state == RM_SERVICE_PROCESSING) {
             /* Forward all new transactions to CD or Server */
-            transactionForwarder(rmInst, transaction);                
-        }
-        else {
+            transactionForwarder(rmInst, transaction);
+        } else {
             /* Transaction validated.  Return result. */
             serviceResponder(rmInst, transaction);
         }
 
         /* Forward any queued static requests that weren't forwarded */
+        transQ = rmInst->transactionQueue;
         while(transQ) {
             if ((transQ->state == RM_SERVICE_APPROVED_STATIC) &&
                 (!transQ->hasBeenForwarded)) {
                 transactionForwarder(rmInst, transQ);
             }
             transQ = transQ->nextTransaction;
-        }        
+        }
     }
     /* Let call stack return transaction result app via Rm_serviceHandler */
 }
@@ -592,62 +937,193 @@ static void clientProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
  *                  - Attempts to complete resource service requests
  *                    received from registered Clients
  */
-static void clientDelegateProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
-{     
-    Rm_StaticAllocCfg  staticAllocCfg;    
-    Rm_Transaction    *transQ = rmInst->transactionQueue;    
+static void cdProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
+{      
+    Rm_Transaction   *newTrans = NULL;
+    Rm_AllocatorNode *allocator = NULL;
+    Rm_Transaction   *transQ;
 
     if (!rmInst->registeredWithDelegateOrServer) {
         if ((transaction->state == RM_SERVICE_PROCESSING) &&
-            (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS) == 0)) {
-            staticAllocCfg.instName = rmInst->instName;
-            staticAllocCfg.staticPolicy = rmInst->u.cd.staticPolicy;
-            staticAllocCfg.staticValidInstTree = rmInst->u.cd.staticValidInstTree;            
-            staticAllocationHandler(&staticAllocCfg, transaction);
+            (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+             RM_NAME_MAX_CHARS) == 0)) {
+            /* Attempt static allocation of requests originating from CD inst */
+            staticAllocationHandler((Rm_Handle)rmInst, transaction);
         }
-        /* Everything else left in transaction queue for forwarding once transport to
-         * Server is registered */
-    }
-    else {
-        if ((transaction->state == RM_SERVICE_PROCESSING) ||
-            (transaction->state == RM_SERVICE_APPROVED_STATIC)) {        
-            if ((transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) ||
-                (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) ||
-                (transaction->type == Rm_service_RESOURCE_UNMAP_NAME)) {
-                /* Forward all NameServer requests. */
-                transactionForwarder(rmInst, transaction);
+        /* Everything else left in transaction queue for forwarding once
+         * transport to Server is registered */
+    } else {
+        if (transaction->pendingTransactionId) {
+            Rm_Transaction *pendingTrans = rmTransactionQueueFind(rmInst,
+                                             transaction->pendingTransactionId);
+
+            /* Transaction is response from Server for transaction sent to get
+             * information in order to complete pending transaction */
+            if (transaction->state == RM_SERVICE_APPROVED) {
+                if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
+                    /* Transfer resource data tied to name to pending
+                     * transaction */
+                    rm_strncpy(pendingTrans->resourceInfo.name,
+                               transaction->resourceInfo.name,
+                               RM_NAME_MAX_CHARS);
+                    pendingTrans->resourceInfo.base   = transaction->resourceInfo.base;
+                    pendingTrans->resourceInfo.length = transaction->resourceInfo.length;
+                    /* Delete NS name from pending transaction so Server isn't
+                     * queried again */
+                    memset(pendingTrans->resourceInfo.nameServerName, 0,
+                           RM_NAME_MAX_CHARS);
+                    /* Now that resource values have been retrieved clear
+                     * pending transaction ID so CD doesn't think a resource
+                     * request was sent to Server already for more local
+                     * resources */
+                    pendingTrans->pendingTransactionId = 0;
+
+                    /* Return original transaction to processing state to
+                     * attempt completion. */
+                    pendingTrans->state = RM_SERVICE_PROCESSING;
+                } else if ((transaction->type ==
+                            Rm_service_RESOURCE_ALLOCATE_INIT) ||
+                           (transaction->type ==
+                            Rm_service_RESOURCE_ALLOCATE_USE)) {
+                    /* Add resources provided by Server to those managed by
+                     * CD */
+                    if ((allocator = rmAllocatorFind((Rm_Handle)rmInst,
+                                             transaction->resourceInfo.name))) {
+                        rmAllocatorAddResNode((Rm_Handle)rmInst,
+                                              allocator,
+                                              transaction->resourceInfo.base,
+                                              transaction->resourceInfo.length);
+                    }
+
+                    /* Return original transaction to processing state to
+                     * attempt completion */
+                    pendingTrans->state = RM_SERVICE_PROCESSING;
+                } else if (transaction->type == Rm_service_RESOURCE_FREE) {
+                    allocator = rmAllocatorFind((Rm_Handle)rmInst,
+                                                transaction->resourceInfo.name);
+
+                    /* Local resource freed on Server.  Remove node in
+                     * local allocator's resource tree as well */
+                    rmAllocatorDeleteResNode((Rm_Handle)rmInst,
+                                             allocator,
+                                             transaction->resourceInfo.base,
+                                             transaction->resourceInfo.length);
+
+                    /* Allow original free to complete */
+                    pendingTrans->state = RM_SERVICE_APPROVED;
+                } else {
+                    pendingTrans->state = RM_ERROR_SERVER_RESP_INVALID_SERVICE_TYPE;
+                }
+            } else {
+                if (transaction->type == Rm_service_RESOURCE_FREE) {
+                    /* Error occurred when trying to free local resource on
+                     * Server.  Reinsert local resources freed by original
+                     * request */
+                    Rm_AllocatorOpInfo   opInfo;
+
+                    memset((void *)&opInfo, 0, sizeof(Rm_AllocatorOpInfo));
+                    opInfo.resourceInfo = &pendingTrans->resourceInfo;
+                    opInfo.serviceInstNode = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
+                                              pendingTrans->serviceSrcInstName);
+                    /* Can't regain the original type of allocate.  Default to
+                     * init */
+                    opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
+                    if (rmAllocatorOperation((Rm_Handle)rmInst, &opInfo) !=
+                        RM_SERVICE_APPROVED) {
+                        transaction->state = RM_ERROR_LOST_RESOURCES_ON_CD;
+                    }
+                }
+                /* Transfer error or denial to pending transaction */
+                pendingTrans->state = transaction->state;
             }
-            else if (transaction->type == Rm_service_RESOURCE_FREE) {
-                freeHandler(rmInst, transaction);
+            rmTransactionQueueDelete(rmInst, transaction->localId);
+            /* Switch to pending transaction */
+            transaction = pendingTrans;
+        }
+
+        if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+            (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) ||
+            (transaction->type == Rm_service_RESOURCE_STATUS) ||
+            (transaction->type == Rm_service_RESOURCE_FREE)) {
+            if ((transaction->state == RM_SERVICE_PROCESSING) &&
+                (strlen(transaction->resourceInfo.nameServerName) > 0)) {
+                /* Create and forward new transaction to Server to
+                 * retrieve resource data mapped to name */
+                if ((newTrans = rmTransactionQueueAdd(rmInst))) {
+                    newTrans->type = Rm_service_RESOURCE_GET_BY_NAME;
+                    rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName,
+                               RM_NAME_MAX_CHARS);
+                    newTrans->state = RM_SERVICE_PROCESSING;
+                    rm_strncpy(newTrans->resourceInfo.nameServerName,
+                               transaction->resourceInfo.nameServerName,
+                               RM_NAME_MAX_CHARS);
+                    newTrans->pendingTransactionId = transaction->localId;
+                    transactionForwarder(rmInst, newTrans);
+
+                    transaction->state = RM_SERVICE_PENDING_SERVER_RESPONSE;
+                } else {
+                    transaction->state = RM_ERROR_TRANS_REQ_TO_SERVER_NOT_CREATED;
+                }
             }
-            else {
-                allocationHandler(rmInst, transaction);
+        }
+
+        if (transaction->state == RM_SERVICE_PROCESSING) {
+            switch(transaction->type) {
+                case Rm_service_RESOURCE_ALLOCATE_INIT:
+                case Rm_service_RESOURCE_ALLOCATE_USE:
+                    allocationHandler(rmInst, transaction);
+                    break;
+                case Rm_service_RESOURCE_FREE:
+                    freeHandler(rmInst, transaction);
+                    break;
+                case Rm_service_RESOURCE_STATUS:
+                    statusHandler(rmInst, transaction);
+                    break;
+                case Rm_service_RESOURCE_MAP_TO_NAME:
+                case Rm_service_RESOURCE_GET_BY_NAME:
+                case Rm_service_RESOURCE_UNMAP_NAME:
+                    /* Forward all NameServer-based transactions */
+                    break;
+                default:
+                    transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
+                    break;
             }
-            
+        }
+
+        if (transaction->state == RM_SERVICE_PROCESSING) {
+            uint32_t transId = transaction->localId;
+
+            /* NameServer transaction or CD could not complete alloc/free
+             * transaction.  Forward to Server */
+            transactionForwarder(rmInst, transaction);
+
+            /* Refresh transaction for reentrancy of cases where mix of Client
+             * CD and Server are running on the same core and connected via
+             * transport implemented over direct function calls instead of
+             * traditional transport that returns after sending the data */
+            transaction = rmTransactionQueueFind(rmInst, transId);
+        }
+
+        if (transaction) {
             if ((transaction->state != RM_SERVICE_PROCESSING) &&
-                (transaction->state != RM_SERVICE_APPROVED_STATIC)) {
-                /* Transaction error occurred.  Return result */
-                if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-                    /* Source of failed transaction was not CD, return transaction via responder */
+                (transaction->state != RM_SERVICE_PENDING_SERVER_RESPONSE)) {
+                /* Transaction completed by CD or completed response received
+                 * from Server.  Return result */
+                if (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+                    RM_NAME_MAX_CHARS)) {
+                    /* Transaction did not originate on this instance */
                     transactionResponder(rmInst, transaction);
+                } else {
+                    /* Transaction originated on this instance */
+                    serviceResponder(rmInst, transaction);
                 }
-                /* Otherwise let call stack return failed transaction result app via Rm_serviceHandler */                
-            }            
-        }
-        else {
-            /* Transaction validated.  Return result. */
-            if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-                /* Transaction did not originate on this instance */
-                transactionResponder(rmInst, transaction);
-            }
-            else {
-                /* Transaction originated on this instance */
-                serviceResponder(rmInst, transaction);
             }
         }
 
-        /* Forward any queued static requests (local and received from any registered
-         * Clients that weren't forwarded */
+        /* Attempt allocation of any queued static requests:
+         * RM_SERVICE_APPROVED_STATIC - Originated locally
+         * RM_SERVICE_PROCESSING - Received from any registered Clients */
+        transQ = rmInst->transactionQueue;
         while(transQ) {
             if (((transQ->state == RM_SERVICE_PROCESSING) ||
                  (transQ->state == RM_SERVICE_APPROVED_STATIC)) &&
@@ -655,7 +1131,7 @@ static void clientDelegateProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
                 transactionForwarder(rmInst, transQ);
             }
             transQ = transQ->nextTransaction;
-        }        
+        }
     }
 }
 
@@ -668,26 +1144,30 @@ static void clientDelegateProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
  *                    the service handle and registered CDs and
  *                    Clients
  */
-static void serverProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void serverProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
-    Rm_NameServerObjCfg  nameServerObjCfg;        
+    Rm_NameServerObjCfg  nameServerObjCfg;
 
     switch (transaction->type) {
+        case Rm_service_RESOURCE_STATUS:
+            statusHandler(rmInst, transaction);
+            break;
         case Rm_service_RESOURCE_ALLOCATE_INIT:
         case Rm_service_RESOURCE_ALLOCATE_USE:
             allocationHandler(rmInst, transaction);
             break;
-        case Rm_service_RESOURCE_FREE:               
+        case Rm_service_RESOURCE_FREE:
             freeHandler(rmInst, transaction);
             break;
         case Rm_service_RESOURCE_MAP_TO_NAME:
         case Rm_service_RESOURCE_GET_BY_NAME:
-        case Rm_service_RESOURCE_UNMAP_NAME:             
+        case Rm_service_RESOURCE_UNMAP_NAME:
             if (rmInst->u.server.nameServer) {
                 if (rmInst->instType == Rm_instType_SHARED_SERVER) {
                     rmNameServerTreeInv(rmInst->u.server.nameServer);
                 }                
-                memset((void *)&nameServerObjCfg, 0, sizeof(Rm_NameServerObjCfg));
+                memset((void *)&nameServerObjCfg, 0,
+                       sizeof(Rm_NameServerObjCfg));
                 nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
                 nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
                 if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
@@ -695,35 +1175,47 @@ static void serverProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
                     nameServerObjCfg.nodeCfg.resourceBase= transaction->resourceInfo.base;
                     nameServerObjCfg.nodeCfg.resourceLength = transaction->resourceInfo.length;
                     transaction->state = rmNameServerAddObject(&nameServerObjCfg);
-                }
-                else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
+                } else if (transaction->type ==
+                           Rm_service_RESOURCE_GET_BY_NAME) {
                     if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==
                         RM_SERVICE_PROCESSING) {
-                        strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+                        rm_strncpy(transaction->resourceInfo.name,
+                                   nameServerObjCfg.nodeCfg.resourceName,
+                                   RM_NAME_MAX_CHARS);
                         transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                         transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
                         transaction->state = RM_SERVICE_APPROVED;
-                    } 
-                }
-                else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
+                    }
+                } else if (transaction->type ==
+                           Rm_service_RESOURCE_UNMAP_NAME) {
                     transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);
+                } else {
+                    transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
                 }
-                
+
                 if (rmInst->instType == Rm_instType_SHARED_SERVER) {
                     rmNameServerTreeWb(rmInst->u.server.nameServer);
                 }
-            }
-            else {
+            } else {
                 transaction->state = RM_ERROR_NAMESERVER_DOES_NOT_EXIST;
             }
             break;
+        default:
+            transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
+            break;
     }
 
-    if (strncmp(transaction->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS)) {
-        /* Source of transaction was not Server, return transaction via responder */
-        transactionResponder(rmInst, transaction);
+    /* Source of shared server transaction will always be local. */
+    if (rmInst->instType != Rm_instType_SHARED_SERVER) {
+        if (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+                    RM_NAME_MAX_CHARS)) {
+            /* Source of transaction was not Server, return transaction via
+             * responder */
+            transactionResponder(rmInst, transaction);
+        }
     }
-    /* Otherwise let call stack return transaction result app via Rm_serviceHandler */ 
+    /* Otherwise let call stack return transaction result app via
+     * Rm_serviceHandler */ 
 }
 
 /**********************************************************************
@@ -753,12 +1245,11 @@ Rm_Transaction *rmTransactionQueueAdd(Rm_Inst *rmInst)
                 transactionQueue = transactionQueue->nextTransaction;
             }
             transactionQueue->nextTransaction = newTransaction;
-        }
-        else {
+        } else {
             rmInst->transactionQueue = newTransaction;
         }
     }
-    return (newTransaction);
+    return(newTransaction);
 }
 
 /* FUNCTION PURPOSE: Finds a transaction
@@ -773,12 +1264,12 @@ Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)
 
     while (transaction) {
         if (transaction->localId == transactionId) {
-            break;             
+            break;
         }
         transaction = transaction->nextTransaction;
     }
 
-    return (transaction);
+    return(transaction);
 }
 
 /* FUNCTION PURPOSE: Deletes a transaction
@@ -788,13 +1279,13 @@ Rm_Transaction *rmTransactionQueueFind(Rm_Inst *rmInst, uint32_t transactionId)
  */
 int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
 {
-    Rm_Transaction *transaction     = rmInst->transactionQueue;
+    Rm_Transaction *transaction = rmInst->transactionQueue;
     Rm_Transaction *prevTransaction = NULL;
-    int32_t         retVal          = RM_OK;
+    int32_t         retVal = RM_OK;
 
     while (transaction) {
         if (transaction->localId == transactionId) {
-            break;             
+            break;
         }
 
         prevTransaction = transaction;
@@ -803,20 +1294,18 @@ int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
 
     if (transaction) {
         if (prevTransaction == NULL) {
-            /* Transaction at start of queue. Map second transaction to start of queue 
-             * as long as more than one transactions. */
+            /* Transaction at start of queue. Map second transaction to start
+             * of queue as long as more than one transactions. */
             rmInst->transactionQueue = transaction->nextTransaction;
-        }
-        else {
+        } else {
             /* Transaction in middle or end of queue. */
             prevTransaction->nextTransaction = transaction->nextTransaction;
         }
         Rm_osalFree((void *)transaction, sizeof(Rm_Transaction));
-    }
-    else {
+    } else {
         retVal = RM_ERROR_SERVICE_TRANS_DOES_NOT_EXIST;
-    }    
-    return (retVal);
+    }
+    return(retVal);
 }
 
 /* FUNCTION PURPOSE: Routes a transaction for processing
@@ -824,19 +1313,20 @@ int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
  * DESCRIPTION: Routes a received transaction to the appropriate
  *              instance processing routine
  */
-void rmProcessRouter (Rm_Inst *rmInst, Rm_Transaction *transaction)
+void rmProcessRouter(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
     if (rmInst->instType == Rm_instType_CLIENT) {
         clientProcess(rmInst, transaction);
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        clientDelegateProcess(rmInst, transaction);
-    }
-    else if (rmInst->instType == Rm_instType_SERVER) {
+    } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        cdProcess(rmInst, transaction);
+    } else if ((rmInst->instType == Rm_instType_SERVER) ||
+               (rmInst->instType == Rm_instType_SHARED_SERVER)) {
         serverProcess(rmInst, transaction);
-    } 
+    } else {
+        transaction->state = RM_ERROR_INVALID_INST_TYPE;
+    }
 }
-     
+
 /**********************************************************************
  ********************** Application visible APIs **********************
  **********************************************************************/
@@ -848,31 +1338,66 @@ void rmProcessRouter (Rm_Inst *rmInst, Rm_Transaction *transaction)
  *              instance network.  Also, prints the NameServer name
  *              entries.  The number of resource range owners is
  *              returned as well.  This function is only available on
- *              server instances.
+ *              Server and CD instances.
  */
-int32_t Rm_resourceStatus(Rm_Handle rmServerHandle, int printResources)
+int32_t Rm_resourceStatus(Rm_Handle rmHandle, int printResources)
 {
-    Rm_Inst         *rmInst = (Rm_Inst *)rmServerHandle;
-    Rm_Allocator    *allocator = NULL;
-    Rm_Owner        *owners;
-    Rm_ResourceTree *treeRoot;
-    Rm_ResourceNode *treeNode;
-    int32_t          totalResOwners = 0;
-    void            *key; 
+    Rm_Inst          *rmInst = (Rm_Inst *)rmHandle;
+    Rm_AllocatorTree *allocTree = NULL;
+    Rm_AllocatorNode *allocator;
+    Rm_Owner         *owners;
+    Rm_ResourceTree  *treeRoot;
+    Rm_ResourceNode  *treeNode;
+    int32_t           totalResOwners = 0;
+    void             *key;
+    void             *mtKey;
+
+    RM_SS_INST_INV_ENTER_CS(rmInst, key);
+    RM_SC_INST_INV_ENTER_CS(rmInst, key);
+    if (rmInst->mtSemObj) {
+        mtKey = Rm_osalMtCsEnter(rmInst->mtSemObj);
+    }
+
+    if (rmInst->instType != Rm_instType_CLIENT) {
+        Rm_osalLog("Instance name: %s\n", rmInst->instName);
+        Rm_osalLog("Handle: 0x%08x\n", rmHandle);
+        if (rmInst->instType == Rm_instType_SERVER) {
+            Rm_osalLog("Type:   Server\n");
+        } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+            Rm_osalLog("Type:   Client Delegate\n");
+        } else if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+            Rm_osalLog("Type:   Shared Server\n");
+        } else if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
+            Rm_osalLog("Type:   Shared Client\n");
+        } else {
+            Rm_osalLog("Type:   UNKNOWN\n");
+            goto errorExit;
+        }
+
+        Rm_osalLog("\nResource Status:\n\n");
+    }
 
-    RM_SS_INST_INV_ENTER_CS(key);
+    if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
+        /* Transfer control to shared server instance */
+        rmInst = rmInst->u.sharedClient.sharedServerHandle;
+    }
 
     if ((rmInst->instType == Rm_instType_SERVER) ||
-        (rmInst->instType == Rm_instType_SHARED_SERVER)) {
-        allocator = rmInst->u.server.allocators;
-        while (allocator) {
-            RM_SS_OBJ_INV(allocator, Rm_Allocator);
+        (rmInst->instType == Rm_instType_SHARED_SERVER) ||
+        (rmInst->instType == Rm_instType_CLIENT_DELEGATE)) {
+
+        allocTree = rmInst->allocatorTree;
+        if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+            rmAllocatorTreeInv(allocTree);
+        }
+
+        RB_FOREACH(allocator, _Rm_AllocatorTree, allocTree) {
+            RM_SS_OBJ_INV(rmInst, allocator, Rm_AllocatorNode);
             if (printResources) {
                 Rm_osalLog("Resource: %s\n", allocator->resourceName);
             }
 
-            treeRoot = allocator->allocatorRootEntry;
-            RM_SS_OBJ_INV(treeRoot, Rm_ResourceTree);
+            treeRoot = allocator->resourceRoot;
             if (rmInst->instType == Rm_instType_SHARED_SERVER) {
                 rmResourceTreeInv(treeRoot);
             }
@@ -881,26 +1406,27 @@ int32_t Rm_resourceStatus(Rm_Handle rmServerHandle, int printResources)
                     if ((treeNode->base >= 65536) ||
                         ((treeNode->base + treeNode->length - 1) >= 65536)) {
                         /* Print in hex if number is very large */
-                        Rm_osalLog("          0x%08x - 0x%08x ", treeNode->base, 
-                                                                 treeNode->base + treeNode->length - 1);
-                    }
-                    else {
-                        Rm_osalLog("          %10d - %10d ", treeNode->base, 
-                                                             treeNode->base + treeNode->length - 1);
+                        Rm_osalLog("          0x%08x - 0x%08x ",
+                                   treeNode->base,
+                                   treeNode->base + treeNode->length - 1);
+                    } else {
+                        Rm_osalLog("          %10d - %10d ",
+                                   treeNode->base,
+                                   treeNode->base + treeNode->length - 1);
                     }
                 }
-                
+
                 if (treeNode->allocationCount == 0) {
                     if (printResources) {
                         Rm_osalLog("FREE\n");
                     }
-                }
-                else {
+                } else {
                     owners = treeNode->ownerList;
                     while (owners) {
-                        RM_SS_OBJ_INV(owners, Rm_Owner);
+                        RM_SS_OBJ_INV(rmInst, owners, Rm_Owner);
                         if (printResources) {
-                            Rm_osalLog("%s ", owners->instNameNode->name);
+                            Rm_osalLog("%s (%d) ", owners->instNameNode->name,
+                                       owners->refCnt);
                         }
                         totalResOwners++;
                         owners = owners->nextOwner;
@@ -909,18 +1435,26 @@ int32_t Rm_resourceStatus(Rm_Handle rmServerHandle, int printResources)
                         Rm_osalLog("\n");
                     }
                 }
-            }        
-            allocator = allocator->nextAllocator; 
+            }
         }
-        if (printResources) {
-            rmNameServerPrintObjects((Rm_Handle)rmInst);
+
+        if ((rmInst->instType == Rm_instType_SERVER) ||
+            (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+            if (printResources) {
+                rmNameServerPrintObjects((Rm_Handle)rmInst);
+            }
         }
-    }
-    else {
+    } else {
         totalResOwners = RM_ERROR_INVALID_RES_STATUS_INSTANCE;
-    }  
+    }
 
-    RM_SS_INST_WB_EXIT_CS(key);
+errorExit:
+    /* Free sem object using originating instance in case the Shared Client to Shared
+     * Server instance switch took place */
+    if (((Rm_Inst *)rmHandle)->mtSemObj) {
+        Rm_osalMtCsExit(((Rm_Inst *)rmHandle)->mtSemObj, mtKey);
+    }
+    RM_SS_INST_WB_EXIT_CS(rmInst, key);
     return(totalResOwners);
 }
 
@@ -935,41 +1469,54 @@ void Rm_instanceStatus(Rm_Handle rmHandle)
     Rm_Inst        *rmInst = (Rm_Inst *)rmHandle;
     Rm_Transport   *transportList = NULL;
     Rm_Transaction *transactionQ = NULL;
-    void           *key; 
+    void           *key;
+    void           *mtKey;
 
-    RM_SS_INST_INV_ENTER_CS(key);
+    RM_SS_INST_INV_ENTER_CS(rmInst, key);
+    RM_SC_INST_INV_ENTER_CS(rmInst, key);
+    if (rmInst->mtSemObj) {
+        mtKey = Rm_osalMtCsEnter(rmInst->mtSemObj);
+    }
 
     Rm_osalLog("Instance name: %s\n", rmInst->instName);
     Rm_osalLog("Handle: 0x%08x\n", rmHandle);    
     if (rmInst->instType == Rm_instType_SERVER) {
         Rm_osalLog("Type:   Server\n");
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+    } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
         Rm_osalLog("Type:   Client Delegate\n");
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT) {
+    } else if (rmInst->instType == Rm_instType_CLIENT) {
         Rm_osalLog("Type:   Client\n");
-    }
-    else if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+    } else if (rmInst->instType == Rm_instType_SHARED_SERVER) {
         Rm_osalLog("Type:   Shared Server\n");
+    } else if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
+        Rm_osalLog("Type:   Shared Client\n");
+
+        Rm_osalLog("\nShared Server Properties:\n");
+        /* Transfer to Shared Server instance to print out transport and
+         * transaction status */
+        rmInst = rmInst->u.sharedClient.sharedServerHandle;
+        Rm_osalLog("Instance name: %s\n", rmInst->instName);
+        Rm_osalLog("Handle: 0x%08x\n", rmHandle);
+    } else {
+        Rm_osalLog("Type:   UNKNOWN\n");
+        goto errorExit;
     }
-    
+
     transportList = rmInst->transports;
     if (transportList) {
         Rm_osalLog("\nRegistered Transports:\n");
         while (transportList) {
-            RM_SS_OBJ_INV(transportList, Rm_Transport);
-            Rm_osalLog("    Remote instName:    %s\n", transportList->remoteInstName);
+            RM_SS_OBJ_INV(rmInst, transportList, Rm_Transport);
             if (transportList->remoteInstType == Rm_instType_SERVER) {
                 Rm_osalLog("    Remote instType:    Server\n");
-            }
-            else if (transportList->remoteInstType == Rm_instType_CLIENT_DELEGATE) {
+            } else if (transportList->remoteInstType ==
+                       Rm_instType_CLIENT_DELEGATE) {
                 Rm_osalLog("    Remote instType:    Client Delegate\n");
-            }
-            else {
+            } else {
                 Rm_osalLog("    Remote instType:    Client\n");
             }
-            Rm_osalLog("    appTransportHandle: 0x%08x\n", transportList->appTransportHandle);
+            Rm_osalLog("    appTransportHandle: 0x%08x\n",
+                       transportList->appTransportHandle);
             Rm_osalLog("\n");
             transportList = transportList->nextTransport;
         }
@@ -979,21 +1526,35 @@ void Rm_instanceStatus(Rm_Handle rmHandle)
     if (transactionQ) {
         Rm_osalLog("\nQueued Service Transactions:\n");
         while (transactionQ) {
-            RM_SS_OBJ_INV(transactionQ, Rm_Transaction);
-            Rm_osalLog("    Service type:       %d\n", transactionQ->type);
+            RM_SS_OBJ_INV(rmInst, transactionQ, Rm_Transaction);
+            Rm_osalLog("    Service type:       %d\n",
+                       transactionQ->type);
             Rm_osalLog("    Service ID:         %d\n", transactionQ->localId);
-            Rm_osalLog("    Service srcInstName %s\n", transactionQ->serviceSrcInstName);
+            Rm_osalLog("    Service srcInstName %s\n",
+                       transactionQ->serviceSrcInstName);
             Rm_osalLog("    Service state:      %d\n", transactionQ->state);
-            Rm_osalLog("    Resource name:      %s\n", transactionQ->resourceInfo.name);
-            Rm_osalLog("    Resource base:      %d\n", transactionQ->resourceInfo.base);
-            Rm_osalLog("    Resource length:    %d\n", transactionQ->resourceInfo.length);
-            Rm_osalLog("    Resource alignment: %d\n", transactionQ->resourceInfo.alignment);
-            Rm_osalLog("    Resource NS name:   %s\n", transactionQ->resourceInfo.nameServerName);
+            Rm_osalLog("    Resource name:      %s\n",
+                       transactionQ->resourceInfo.name);
+            Rm_osalLog("    Resource base:      %d\n",
+                       transactionQ->resourceInfo.base);
+            Rm_osalLog("    Resource length:    %d\n",
+                       transactionQ->resourceInfo.length);
+            Rm_osalLog("    Resource alignment: %d\n",
+                       transactionQ->resourceInfo.alignment);
+            Rm_osalLog("    Resource NS name:   %s\n",
+                       transactionQ->resourceInfo.nameServerName);
             Rm_osalLog("\n");
             transactionQ = transactionQ->nextTransaction;
-        }    
+        }
     }
-    RM_SS_INST_WB_EXIT_CS(key);    
+
+errorExit:
+    /* Free sem object using originating instance in case the Shared Client
+     * to Shared Server instance switch took place */
+    if (((Rm_Inst *)rmHandle)->mtSemObj) {
+        Rm_osalMtCsExit(((Rm_Inst *)rmHandle)->mtSemObj, mtKey);
+    }
+    RM_SS_INST_WB_EXIT_CS(rmInst, key);
 }
 
 /* FUNCTION PURPOSE: RM instance creation and initialization
@@ -1004,13 +1565,15 @@ void Rm_instanceStatus(Rm_Handle rmHandle)
  */
 Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
 {
-    Rm_Inst *rmInst = NULL;
-    void    *globalResourceDtb = NULL;
-    void    *linuxResourceDtb = NULL;
-    int      addLinux = RM_FALSE;   
+    Rm_Inst  *rmInst = NULL;
+    void     *grlDtb = NULL;
+    void     *policyDtb = NULL;
+    void     *linuxDtb = NULL;
+    int       addLinux = RM_FALSE;
+    void     *key;
 
     *result = RM_OK;
-    
+
     if ((initCfg->instName == NULL) ||
         ((strlen(initCfg->instName) + 1) > RM_NAME_MAX_CHARS)) {
         *result = RM_ERROR_INVALID_INST_NAME;
@@ -1023,14 +1586,15 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
     }
 
     /* Create and initialize instance */
-    rmInst = Rm_osalMalloc (sizeof(Rm_Inst));
-    memset ((void *) rmInst, 0, sizeof(Rm_Inst));
+    rmInst = Rm_osalMalloc(sizeof(*rmInst));
+    memset((void *)rmInst, 0, sizeof(*rmInst));
     rmInst->isLocked = RM_FALSE;
     rmInst->registeredWithDelegateOrServer = RM_FALSE;
     rmInst->transactionSeqNum = transactionInitSequenceNum();
 
-    rmInst->instType = initCfg->instType;    
-    strncpy (rmInst->instName, initCfg->instName, RM_NAME_MAX_CHARS);
+    rmInst->instType = initCfg->instType;
+    rm_strncpy(rmInst->instName, initCfg->instName, RM_NAME_MAX_CHARS);
+    rmInst->mtSemObj = initCfg->mtSemObj;
 
     if ((rmInst->instType == Rm_instType_SERVER) ||
         (rmInst->instType == Rm_instType_SHARED_SERVER)) {
@@ -1040,93 +1604,115 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
             goto errorExit;
         }
 
-        rmInst->u.server.globalPolicy = initCfg->instCfg.serverCfg.globalPolicy;
-
         if (initCfg->instCfg.serverCfg.linuxDtb) {
-            linuxResourceDtb = initCfg->instCfg.serverCfg.linuxDtb;
+            linuxDtb = initCfg->instCfg.serverCfg.linuxDtb;
             addLinux = RM_TRUE;
         }
 
-        /* Create valid instance list from policy.  Must be done prior to parsing
-         * GRL so that Linux resources can be reserved correctly */
-        rmInst->u.server.globalValidInstTree = rmPolicyCreateValidInstTree(rmInst->u.server.globalPolicy, 
-                                                                           addLinux, result);
-        if (*result == RM_OK) {
-            *result = rmPolicyValidatePolicy(rmInst->u.server.globalPolicy, rmInst->u.server.globalValidInstTree);  
+        /* Create valid instance list from policy.  Must be done prior to
+         * parsing GRL so that Linux resources can be reserved correctly */
+        policyDtb = initCfg->instCfg.serverCfg.globalPolicy;
+        rmInst->validInstTree = rmPolicyVInstTreeInit(rmInst, policyDtb,
+                                                      addLinux, result);
+        if (*result != RM_OK) {
+            goto errorExit;
         }
-        
+
+        rmNameServerInit((Rm_Handle)rmInst);
+        grlDtb = initCfg->instCfg.serverCfg.globalResourceList;
+        if ((*result = rmAllocatorTreeInit(rmInst, grlDtb,
+                                           policyDtb, linuxDtb)) != RM_OK) {
+            goto errorExit;
+        }
+    } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
+        if (!initCfg->instCfg.cdCfg.cdPolicy) {
+            *result = RM_ERROR_INVALID_CD_CONFIGURATION;
+            goto errorExit;
+        }
+
+        policyDtb = initCfg->instCfg.cdCfg.cdPolicy;
+        rmInst->validInstTree = rmPolicyVInstTreeInit(rmInst, policyDtb,
+                                                      addLinux, result);
         if (*result != RM_OK) {
-            if (rmInst->u.server.globalValidInstTree) {
-                rmPolicyFreeValidInstTree(rmInst->u.server.globalValidInstTree);
-            }
             goto errorExit;
         }
-        else {
-            rmNameServerInit((Rm_Handle)rmInst);
 
-            globalResourceDtb = initCfg->instCfg.serverCfg.globalResourceList;
+        if ((*result = rmAllocatorTreeInit(rmInst, NULL,
+                                           policyDtb, NULL)) != RM_OK) {
+            goto errorExit;
+        }
 
-            if ((*result = rmAllocatorInitializeResources((Rm_Handle) rmInst, globalResourceDtb, linuxResourceDtb)) == RM_OK) {  
-                *result = rmPolicyValidatePolicyResourceNames(rmInst->u.server.globalPolicy, (void *)rmInst->u.server.allocators);
-            }
+        /* Remove once CD instance is stable - tracked by SDOCM00100797 */
+        *result = RM_WARNING_CD_INSTANCE_NOT_STABLE;
 
+    } else if (rmInst->instType == Rm_instType_CLIENT) {
+        if (initCfg->instCfg.clientCfg.staticPolicy) {
+            policyDtb = initCfg->instCfg.clientCfg.staticPolicy;
+            rmInst->validInstTree = rmPolicyVInstTreeInit(rmInst, policyDtb,
+                                                          addLinux, result);
             if (*result != RM_OK) {
-                rmAllocatorDeleteResources(rmInst->u.server.allocators);
-                rmNameServerDelete((Rm_Handle)rmInst);
                 goto errorExit;
             }
-        }
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        if (initCfg->instCfg.clientCfg.staticPolicy) {
-            rmInst->u.cd.staticPolicy = initCfg->instCfg.cdCfg.staticPolicy;
-            rmInst->u.cd.staticValidInstTree = rmPolicyCreateValidInstTree(rmInst->u.cd.staticPolicy, 
-                                                                           addLinux, result);        
-            if (*result == RM_OK) {
-                *result = rmPolicyValidatePolicy(rmInst->u.cd.staticPolicy, rmInst->u.cd.staticValidInstTree);
-            }
 
-            if (*result != RM_OK) {
-                if (rmInst->u.cd.staticValidInstTree) {
-                    rmPolicyFreeValidInstTree(rmInst->u.cd.staticValidInstTree);
-                }
+            if ((*result = rmAllocatorTreeInit(rmInst, NULL,
+                                               policyDtb, NULL)) != RM_OK) {
                 goto errorExit;
             }
         }
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT) {
-        if (initCfg->instCfg.cdCfg.staticPolicy) { 
-            rmInst->u.client.staticPolicy = initCfg->instCfg.clientCfg.staticPolicy;
-            rmInst->u.client.staticValidInstTree = rmPolicyCreateValidInstTree(rmInst->u.client.staticPolicy, 
-                                                                               addLinux, result);        
-            if (*result == RM_OK) {
-                *result = rmPolicyValidatePolicy(rmInst->u.client.staticPolicy, rmInst->u.client.staticValidInstTree);
-            }
-            
-            if (*result != RM_OK) {
-                if (rmInst->u.client.staticValidInstTree) {
-                    rmPolicyFreeValidInstTree(rmInst->u.client.staticValidInstTree);
-                }
+        
+    } else if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
+        Rm_Handle  sHdl = initCfg->instCfg.sharedClientCfg.sharedServerHandle;
+        Rm_Inst   *ssInst = NULL;
+
+        if (sHdl) {
+            rmInst->u.sharedClient.sharedServerHandle = sHdl;
+            /* Invalidate the Shared server instance structure on this core to
+             * get the latest instance data. */
+            key = Rm_osalCsEnter();
+            Rm_osalBeginMemAccess((void *)sHdl, sizeof(Rm_Inst));
+            ssInst = rmInst->u.sharedClient.sharedServerHandle;
+            if (ssInst->instType != Rm_instType_SHARED_SERVER) {
+                *result = RM_ERROR_INVALID_SHARED_SERVER_HANDLE;
+                Rm_osalCsExit(key);
                 goto errorExit;
+            } else {
+                /* Invalidate all the trees */
+                rmPolicyValidInstTreeInv(ssInst->validInstTree);
+                rmAllocatorTreeInv(ssInst->allocatorTree);
+                rmNameServerTreeInv(ssInst->u.server.nameServer);
             }
+            Rm_osalCsExit(key);
+        } else {
+            *result = RM_ERROR_INVALID_SHARED_SERVER_HANDLE;
+            goto errorExit;
         }
+    } else {
+        *result = RM_ERROR_INVALID_INST_TYPE;
+        goto errorExit;
     }
 
-    if (initCfg->instType == Rm_instType_SHARED_SERVER) {
-        /* Invalidate the instance for other cores */
-        Rm_osalEndMemAccess ((void *)rmInst, sizeof(Rm_Inst));
-    }
-    else {
+    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+        /* Writeback instance and trees for other cores */
+        rmPolicyValidInstTreeWb(rmInst->validInstTree);
+        rmAllocatorTreeWb(rmInst->allocatorTree);
+        rmNameServerTreeWb(rmInst->u.server.nameServer);
+        Rm_osalEndMemAccess((void *)rmInst, sizeof(*rmInst));
+    } else if (rmInst->instType != Rm_instType_SHARED_CLIENT) {
         /* Create the instance's task blocking mechanism */
         rmInst->blockHandle = Rm_osalTaskBlockCreate();
     }
+    /* else: just return handle */
+
+    return((Rm_Handle)rmInst);
 
-    return ((Rm_Handle) rmInst);
 errorExit:
     if (rmInst) {
-        Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));
+        rmAllocatorTreeDelete((Rm_Handle)rmInst);
+        rmNameServerDelete((Rm_Handle)rmInst);
+        rmPolicyVInstTreeDelete((Rm_Handle)rmInst);
+        Rm_osalFree((void *)rmInst, sizeof(*rmInst));
     }
-    return (NULL); 
+    return(NULL);
 }
 
 /* FUNCTION PURPOSE: Deletes an RM instance
@@ -1138,51 +1724,46 @@ errorExit:
 int32_t Rm_delete(Rm_Handle rmHandle, int ignorePendingServices)
 {
     Rm_Inst *rmInst = (Rm_Inst *)rmHandle;
-    void    *key; 
+    void    *key;
 
-    RM_SS_INST_INV_ENTER_CS(key);
+    key = Rm_osalCsEnter();
+    if (rmInst->instType == Rm_instType_SHARED_SERVER) {
+        Rm_osalBeginMemAccess((void *)rmInst, sizeof(*rmInst));
+    }
 
     if (rmInst->serviceHandle) {
-        return (RM_ERROR_CANT_DELETE_WITH_OPEN_SERV_HNDL);
-    }
-    else if (rmInst->transports) {
-        return (RM_ERROR_CANT_DELETE_WITH_REGD_TRANSPORT);
-    }
-    else if (rmInst->transactionQueue && !ignorePendingServices) {
-        return (RM_ERROR_CANT_DELETE_PENDING_TRANSACTIONS);
+        return(RM_ERROR_CANT_DELETE_WITH_OPEN_SERV_HNDL);
+    } else if (rmInst->transports) {
+        return(RM_ERROR_CANT_DELETE_WITH_REGD_TRANSPORT);
+    } else if (rmInst->transactionQueue && !ignorePendingServices) {
+        return(RM_ERROR_CANT_DELETE_PENDING_TRANSACTIONS);
     }
+    /* else: delete instance since no more deletion failure cases */
 
-    if ((rmInst->instType == Rm_instType_SERVER) ||
-        (rmInst->instType == Rm_instType_SHARED_SERVER)) {
-        rmAllocatorDeleteResources(rmInst->u.server.allocators);
-        rmPolicyFreeValidInstTree(rmInst->u.server.globalValidInstTree);
+    if (rmInst->instType != Rm_instType_SHARED_CLIENT) {
         rmNameServerDelete(rmHandle);
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        rmPolicyFreeValidInstTree(rmInst->u.cd.staticValidInstTree);
-    }
-    else if (rmInst->instType == Rm_instType_CLIENT) {
-        rmPolicyFreeValidInstTree(rmInst->u.client.staticValidInstTree);
-    }
+        rmAllocatorTreeDelete(rmHandle);
+        rmPolicyVInstTreeDelete(rmHandle);
 
-    /* Delete any transactions */
-    while(rmInst->transactionQueue) {
-        rmTransactionQueueDelete(rmInst, rmInst->transactionQueue->localId);
-    }
+        /* Delete any transactions */
+        while(rmInst->transactionQueue) {
+            rmTransactionQueueDelete(rmInst, rmInst->transactionQueue->localId);
+        }
 
-    if (rmInst->instType != Rm_instType_SHARED_SERVER) {
-        /* Delete the instance's task blocking mechanism */
-        Rm_osalTaskBlockDelete(rmInst->blockHandle);
-    }
-    else {
-        Rm_osalEndMemAccess((void *)rmInst, sizeof(Rm_Inst));
+        if (rmInst->instType != Rm_instType_SHARED_SERVER) {
+            /* Delete the instance's task blocking mechanism */
+            Rm_osalTaskBlockDelete(rmInst->blockHandle);
+        } else {
+            rmInst->allocatorTree       = NULL;
+            rmInst->validInstTree       = NULL;
+            rmInst->u.server.nameServer = NULL;
+            Rm_osalEndMemAccess((void *)rmInst, sizeof(*rmInst));
+        }
     }
 
-    Rm_osalFree((void *)rmInst, sizeof(Rm_Inst));
-    if (rmInst->instType == Rm_instType_SHARED_SERVER) {    
-        Rm_osalCsExit(key);   
-    }
-    return (RM_OK);
+    Rm_osalFree((void *)rmInst, sizeof(*rmInst));
+    Rm_osalCsExit(key);
+    return(RM_OK);
 }
 
 /* FUNCTION PURPOSE: Returns RM version information
@@ -1190,7 +1771,7 @@ int32_t Rm_delete(Rm_Handle rmHandle, int ignorePendingServices)
  */
 uint32_t Rm_getVersion(void)
 {
-    return RM_VERSION_ID;
+    return(RM_VERSION_ID);
 }
 
 /* FUNCTION PURPOSE: Returns RM version string
@@ -1198,6 +1779,6 @@ uint32_t Rm_getVersion(void)
  */
 const char* Rm_getVersionStr(void)
 {
-    return rmVersionStr;
+    return(rmVersionStr);
 }