Index: trunk/kernel/libk/remote_sem.h
===================================================================
--- trunk/kernel/libk/remote_sem.h	(revision 457)
+++ trunk/kernel/libk/remote_sem.h	(revision 563)
@@ -1,6 +1,6 @@
 /*
- * remote_sem.h - POSIX unnammed semaphore definition.
+ * remote_sem.h - POSIX unnamed semaphore definition.
  * 
- * Author   Alain Greiner    (2016)
+ * Author   Alain Greiner (2016,2017,2018)
  *
  * Copyright (c)  UPMC Sorbonne Universites
@@ -10,5 +10,5 @@
  * ALMOS-MKH is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2.0 of the License.
+e* the Free Software Foundation; version 2.0 of the License.
  *
  * ALMOS-MKH is distributed in the hope that it will be useful, but
@@ -27,32 +27,33 @@
 #include <hal_kernel_types.h>
 #include <xlist.h>
-#include <remote_spinlock.h>
+#include <remote_busylock.h>
 
-/*********************************************************************************************
- *      This file defines a POSIX compliant unnamed semaphore.
+/********************************************************************************************n
+ * This is the kernel representation of an user level, POSIX compliant unnamed semaphore.
  *
- * A semaphore is declared by a given user process as a "sem_t" global variable.
+ * It can be used by muti-threaded user applications to synchronise user threads
+ * running in different clusters.
+ *
+* A semaphore is declared by a given user process as a "sem_t" global variable.
  * The user "sem_t" structure is implemented as an unsigned long, but the value is not
  * used by the kernel. ALMOS-MKH uses only the sem_t virtual address as an identifier.
- * For each user semaphore, ALMOS-MKH creates a kernel "remote_sem_t" structure.
- * - This structure is allocated in the reference cluster by the sem_init() syscall, 
- *   and destroyed by the sem_destroy() syscall, using RPC if the calling thread is not
- *   running in the reference cluster.
- * - The threads accessing the semaphore with the sem_get_value(), sem_wait(), sem_post()
- *   syscalls can be running in any cluster, as these syscalls access the "remote_sem_t"
- *   structure with remote_read / remote_write access functions.
+ * For each user semaphore, ALMOS-MKH creates a kernel "remote_sem_t" structure,
+ * dynamically allocated in the reference cluster by the remote_sem_create() function, 
+ * and destroyed by the remote_sem_destroy() function, using RPC if the calling thread is not
+ * running in the reference cluster.
+ *
+ * The threads accessing the semaphore with the sem_get_value(), sem_wait(), sem_post()
+ * syscalls can be running in any cluster, as these syscalls access the "remote_sem_t"
+ * structure with remote_read / remote_write access functions.
  ********************************************************************************************/
 
 
 /*********************************************************************************************
- * This structure defines the kernel semaphore descriptor.
- * - It contains the root of a waiting threads queue, implemented as a distributed xlist.
- * - It contains an xlist of all semaphores, rooted in the reference process descriptor.
- * - It contains a lock protecting both the semaphore value and the waiting queue.
+ * This structure defines the kernel implementation of an user level semaphore.
  ********************************************************************************************/
 
 typedef struct remote_sem_s
 {
-	remote_spinlock_t lock;          /*! lock protecting both count and wait_queue          */
+	remote_busylock_t lock;          /*! lock protecting the semaphore state                */
 	uint32_t          count;         /*! current value                                      */
     intptr_t          ident;         /*! virtual address in user space == identifier        */
@@ -66,11 +67,11 @@
  * This function returns an extended pointer on the remote semaphore identified
  * by its virtual address in a given user process. It makes an associative search, 
- * scanning the list of semaphores rooted in the reference process descriptor.
+ * scanning the list of user semaphores rooted in the reference process descriptor.
  *********************************************************************************************
  * @ process  : pointer on local process descriptor.
- * @ vaddr    : semaphore virtual address, used as identifier.
+ * @ ident    : semaphore virtual address, used as identifier.
  * @ returns extended pointer on semaphore if success / returns XPTR_NULL if not found. 
  ********************************************************************************************/
-xptr_t remote_sem_from_vaddr( intptr_t  vaddr );
+xptr_t remote_sem_from_ident( intptr_t  ident );
 
 /*********************************************************************************************
@@ -78,15 +79,12 @@
  * It allocates memory for a remote semaphore in reference cluster, using a RPC if required, 
  * and initializes it, using remote accesses from values defined by the <vaddr> and <value>
- * arguments. It uses also a remote access to return the extended pointer on the semaphore 
- * in the buffer identified by the <buf_xp> argument.
+ * arguments. It register this semaphore in the calling process list of user semaphores.
  *********************************************************************************************
  * @ vaddr     : [in] semaphore virtual address, used as identifier.
  * @ value     : [in] semaphore initial value.
- * @ sem_xp_xp : [out] extended pointer on buffer to store extended pointer on semaphore.
  * @ returns 0 if success / returns -1 if no memory. 
  ********************************************************************************************/
 error_t remote_sem_create( intptr_t  vaddr,
-                           uint32_t  value,
-                           xptr_t    sem_xp_xp );
+                           uint32_t  value );
  
 /****************************yy***************************************************************
@@ -101,8 +99,8 @@
 /****************************yy***************************************************************
  * This blocking function implements the SEM_WAIT operation.
- * - It returns only when the remote semaphore has a non-zero value,
- *   and has been atomically decremented.
- * -  if the semaphore has a zero value, it register the calling thread in the semaphore
- *    waiting queue, block the thread, and yield.
+ * - It returns only when the remote semaphore has a non-zero value, and has been 
+ *   atomically decremented.
+ * - If the semaphore has a zero value, it register the calling thread in the semaphore
+ *   waiting queue, block the thread, and yield.
  *********************************************************************************************
  * @ sem_xp   : [in] extended pointer on semaphore. 
@@ -112,6 +110,6 @@
 /****************************yy***************************************************************
  * This function mplements the SEM_POST operation.
- * - It atomically increments the remote semaphore if the semaphore waiting queue is empty. 
- * - If the waiting queue is not empty, it wakes up the first waiting thread.
+ * - It atomically increments the remote semaphore. 
+ * - If the waiting queue is not empty, it wakes up all waiting thread.
  *********************************************************************************************
  * @ sem_xp   : [in] extended pointer on semaphore. 
