Index: trunk/kernel/libk/grdxt.h
===================================================================
--- trunk/kernel/libk/grdxt.h	(revision 626)
+++ trunk/kernel/libk/grdxt.h	(revision 635)
@@ -36,7 +36,8 @@
  * Memory for the second and third levels arrays is dynamically allocated by the
  * grdxt_insert() function and is only released by grdxt_destroy().
- * - This structure is entirely contained in one single cluster.
- * - All modifications (insert / remove) must be done by a thread running in local cluster.
- * - Lookup can be done by a thread running in any cluster (local or remote).
+ * This structure is entirely contained in one single cluster, but to allow any thread
+ * to access it, two sets of access functions are defined:
+ * - local threads can use access function using local pointers.
+ * - remote threads must use the access functions using extended pointers.
  ******************************************************************************************
  * When it is used by the mapper implementing the file cache:
@@ -54,6 +55,11 @@
 grdxt_t;
 
+////////////////////////////////////////////////////////////////////////////////////////////
+//                       Local access functions
+////////////////////////////////////////////////////////////////////////////////////////////
+
 /*******************************************************************************************
  * This function initialises the radix-tree descriptor,
+ * It must be called by a local thread.
  * and allocates memory for the first level array of pointers.
  *******************************************************************************************
@@ -71,5 +77,6 @@
 /*******************************************************************************************
  * This function releases all memory allocated to the radix-tree infrastructure.
- * The radix-tree is supposed to be empty, but this is NOT checked by this function.
+ * It must be called by a local thread.
+ * A warning message is printed on the kernel TXT0 if the radix tree is not empty.
  *******************************************************************************************
  * @ rt      : pointer on the radix-tree descriptor.
@@ -79,4 +86,5 @@
 /*******************************************************************************************
  * This function insert a new item in the radix-tree.
+ * It must be called by a local thread.
  * It dynamically allocates memory for new second and third level arrays if required.
  *******************************************************************************************
@@ -84,5 +92,5 @@
  * @ key     : key value.
  * @ value   : pointer on item to be registered in radix-tree.
- * @ returns 0 if success / returns ENOMEM if no memory, or EINVAL if illegal key.
+ * @ returns 0 if success / returns -1 if no memory, or illegal key.
  ******************************************************************************************/
 error_t grdxt_insert( grdxt_t  * rt,
@@ -91,6 +99,7 @@
 
 /*******************************************************************************************
- * This function removes an item identified by its key, and returns a pointer
- * on the removed item. No memory is released.
+ * This function removes an item identified by its key from the radix tree,
+ * It must be called by a local thread.
+ * and returns a pointer on the removed item. No memory is released.
  *******************************************************************************************
  * @ rt      : pointer on the radix-tree descriptor.
@@ -103,4 +112,5 @@
 /*******************************************************************************************
  * This function returns to a local client, a local pointer on the item identified 
+ * It must be called by a local thread.
  * by the <key> argument, from the radix tree identified by the <rt> local pointer.
  *******************************************************************************************
@@ -113,17 +123,6 @@
 
 /*******************************************************************************************
- * This function returns to a - possibly remote - remote client, an extended pointer
- * on the item identified by the <key> argument, from the radix tree identified by
- * the <rt_xp> remote pointer.
- *******************************************************************************************
- * @ rt_xp   : extended pointer on the radix-tree descriptor.
- * @ key     : key value.
- * @ returns an extended pointer on found item if success / returns XPTR_NULL if failure.
- ******************************************************************************************/
-xptr_t grdxt_remote_lookup( xptr_t     rt_xp, 
-                            uint32_t   key );
-
-/*******************************************************************************************
  * This function scan all radix-tree entries in increasing key order, starting from
+ * It must be called by a local thread.
  * the value defined by the <key> argument, and return a pointer on the first valid
  * registered item, and the found item key value.
@@ -138,4 +137,44 @@
                         uint32_t * found_key );
 
+////////////////////////////////////////////////////////////////////////////////////////////
+//                       Remote access functions
+////////////////////////////////////////////////////////////////////////////////////////////
+
+/*******************************************************************************************
+ * This function insert a new item in a - possibly remote - radix tree.
+ * It dynamically allocates memory for new second and third level arrays if required.
+ *******************************************************************************************
+ * @ rt_xp   : extended pointer on the radix-tree descriptor.
+ * @ key     : key value.
+ * @ value   : pointer on item to be registered in radix-tree.
+ * @ returns 0 if success / returns -1 if no memory, or illegal key.
+ ******************************************************************************************/
+error_t grdxt_remote_insert( xptr_t     rt_xp,
+                             uint32_t   key,
+                             void     * value );
+
+/*******************************************************************************************
+ * This function removes an item identified by its key from a - possibly remote - radix
+ * tree, and returns a local pointer on the removed item. No memory is released.
+ *******************************************************************************************
+ * @ rt_xp   : pointer on the radix-tree descriptor.
+ * @ key     : key value.
+ * @ returns local pointer on removed item if success / returns NULL if failure.
+ ******************************************************************************************/
+void * grdxt_remote_remove( xptr_t    rt_xp,
+                            uint32_t  key );
+
+/*******************************************************************************************
+ * This function returns to a - possibly remote - client, an extended pointer
+ * on the item identified by the <key> argument, from the radix tree identified by
+ * the <rt_xp> remote pointer.
+ *******************************************************************************************
+ * @ rt_xp   : extended pointer on the radix-tree descriptor.
+ * @ key     : key value.
+ * @ returns an extended pointer on found item if success / returns XPTR_NULL if failure.
+ ******************************************************************************************/
+xptr_t grdxt_remote_lookup( xptr_t     rt_xp, 
+                            uint32_t   key );
+
 /*******************************************************************************************
  * This function displays the current content of a possibly remote radix_tree.
@@ -144,7 +183,6 @@
  * @ string  : radix tree identifier. 
  ******************************************************************************************/
-void grdxt_display( xptr_t    rt_xp,
-                    char    * string );
-
+void grdxt_remote_display( xptr_t    rt_xp,
+                           char    * string );
 
 #endif	/* _GRDXT_H_ */
