Re: [PATCH] [RTEMS] Always use atomic builtins for libstdc++

2016-09-27 Thread Sebastian Huber

On 22/09/16 12:55, Jonathan Wakely wrote:

[...]
N.B. if you're going to require libatomic for RTEMS then you should
check if the preprocessor conditions in libsupc++/exception_ptr.h
and libsupc++/eh_ptr.cc are appropriate. If exception_ptr is not
currently enabled for RTEMS then you could enable it, since libatomic
will ensure the required atomics are available. 


Thanks for the hint. I added a ticket for RTEMS:

http://devel.rtems.org/ticket/2791

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: What to do with Thread_Control::resource_count?

2016-09-27 Thread Sebastian Huber

On 23/09/16 15:45, Gedare Bloom wrote:

Rather than using refcnts, is there a costlier method (e.g. iterating
some structures) to discover a thread is holding a mutex at this point
of thread destruction that makes sense to use instead?


For the Classic and POSIX object based mutexes this would be possible, 
but not for the self-contained objects. A global registration needs 
memory and you have to register/unregister an object. One aim of the 
self-contained objects is to avoid both overheads.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH] score: Unify CORE mutex seize/surrender

2016-09-27 Thread Sebastian Huber
Use the Thread_Control::resource_count for the no protocol mutexes.
Merge the no protocol and priority inherit CORE mutex seize/surrender
operations.
---
 cpukit/libnetworking/rtems/rtems_glue.c  |  2 +
 cpukit/posix/src/mutexlocksupp.c |  3 +-
 cpukit/posix/src/mutexunlock.c   |  3 +-
 cpukit/rtems/src/semobtain.c |  3 +-
 cpukit/rtems/src/semrelease.c|  4 +-
 cpukit/score/include/rtems/score/coremuteximpl.h | 93 ++--
 cpukit/score/src/apimutexlock.c  |  1 +
 cpukit/score/src/apimutexunlock.c|  1 +
 8 files changed, 18 insertions(+), 92 deletions(-)

diff --git a/cpukit/libnetworking/rtems/rtems_glue.c 
b/cpukit/libnetworking/rtems/rtems_glue.c
index 9a7f82f..46f8765 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -379,6 +379,7 @@ rtems_bsdnet_semaphore_obtain (void)
_Thread_queue_Context_set_no_timeout( &queue_context );
status = _CORE_recursive_mutex_Seize (
&the_networkSemaphore->Core_control.Mutex.Recursive,
+   CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
_Thread_Executing,
true,   /* wait */
_CORE_recursive_mutex_Seize_nested,
@@ -412,6 +413,7 @@ rtems_bsdnet_semaphore_release (void)
_ISR_lock_ISR_disable(&queue_context.Lock_context.Lock_context);
status = _CORE_recursive_mutex_Surrender(
&the_networkSemaphore->Core_control.Mutex.Recursive,
+   CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
_Thread_Executing,
&queue_context
);
diff --git a/cpukit/posix/src/mutexlocksupp.c b/cpukit/posix/src/mutexlocksupp.c
index 1da6238..ea4c4e3 100644
--- a/cpukit/posix/src/mutexlocksupp.c
+++ b/cpukit/posix/src/mutexlocksupp.c
@@ -76,7 +76,7 @@ int _POSIX_Mutex_Lock_support(
   );
   break;
 case POSIX_MUTEX_NO_PROTOCOL:
-  status = _CORE_recursive_mutex_Seize_no_protocol(
+  status = _CORE_recursive_mutex_Seize(
 &the_mutex->Mutex.Recursive,
 POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
 executing,
@@ -89,6 +89,7 @@ int _POSIX_Mutex_Lock_support(
   _Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
   status = _CORE_recursive_mutex_Seize(
 &the_mutex->Mutex.Recursive,
+CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
 executing,
 wait,
 _POSIX_Mutex_Lock_nested,
diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c
index 3144314..c15f7e6 100644
--- a/cpukit/posix/src/mutexunlock.c
+++ b/cpukit/posix/src/mutexunlock.c
@@ -53,7 +53,7 @@ int pthread_mutex_unlock(
   );
   break;
 case POSIX_MUTEX_NO_PROTOCOL:
-  status = _CORE_recursive_mutex_Surrender_no_protocol(
+  status = _CORE_recursive_mutex_Surrender(
 &the_mutex->Mutex.Recursive,
 POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
 executing,
@@ -64,6 +64,7 @@ int pthread_mutex_unlock(
   _Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
   status = _CORE_recursive_mutex_Surrender(
 &the_mutex->Mutex.Recursive,
+CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
 executing,
 &queue_context
   );
diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
index 9afef54..b81612e 100644
--- a/cpukit/rtems/src/semobtain.c
+++ b/cpukit/rtems/src/semobtain.c
@@ -75,6 +75,7 @@ rtems_status_code rtems_semaphore_obtain(
 case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
   status = _CORE_recursive_mutex_Seize(
 &the_semaphore->Core_control.Mutex.Recursive,
+CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
 executing,
 wait,
 _CORE_recursive_mutex_Seize_nested,
@@ -91,7 +92,7 @@ rtems_status_code rtems_semaphore_obtain(
   );
   break;
 case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
-  status = _CORE_recursive_mutex_Seize_no_protocol(
+  status = _CORE_recursive_mutex_Seize(
 &the_semaphore->Core_control.Mutex.Recursive,
 _Semaphore_Get_operations( the_semaphore ),
 executing,
diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c
index 39c467d..40860a1 100644
--- a/cpukit/rtems/src/semrelease.c
+++ b/cpukit/rtems/src/semrelease.c
@@ -52,6 +52,7 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
 case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
   status = _CORE_recursive_mutex_Surrender(
 &the_semaphore->Core_control.Mutex.Recursive,
+CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
 executing,
 &queue_context
   );
@@ -64,13 +65,12 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
   );
   break;
 case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
-  _CORE_recursive_mutex_Surrender_no_protocol(
+  status = _CORE_recursive_mutex_Sur

Re: [PATCH] score: Unify CORE mutex seize/surrender

2016-09-27 Thread Gedare Bloom
OK. A mostly unrelated question: why do we have two different
_Semaphore_Get functions, one static in score/src/semaphore.c and the
other inlined from semimpl.h?

On Tue, Sep 27, 2016 at 9:25 AM, Sebastian Huber
 wrote:
> Use the Thread_Control::resource_count for the no protocol mutexes.
> Merge the no protocol and priority inherit CORE mutex seize/surrender
> operations.
> ---
>  cpukit/libnetworking/rtems/rtems_glue.c  |  2 +
>  cpukit/posix/src/mutexlocksupp.c |  3 +-
>  cpukit/posix/src/mutexunlock.c   |  3 +-
>  cpukit/rtems/src/semobtain.c |  3 +-
>  cpukit/rtems/src/semrelease.c|  4 +-
>  cpukit/score/include/rtems/score/coremuteximpl.h | 93 
> ++--
>  cpukit/score/src/apimutexlock.c  |  1 +
>  cpukit/score/src/apimutexunlock.c|  1 +
>  8 files changed, 18 insertions(+), 92 deletions(-)
>
> diff --git a/cpukit/libnetworking/rtems/rtems_glue.c 
> b/cpukit/libnetworking/rtems/rtems_glue.c
> index 9a7f82f..46f8765 100644
> --- a/cpukit/libnetworking/rtems/rtems_glue.c
> +++ b/cpukit/libnetworking/rtems/rtems_glue.c
> @@ -379,6 +379,7 @@ rtems_bsdnet_semaphore_obtain (void)
> _Thread_queue_Context_set_no_timeout( &queue_context );
> status = _CORE_recursive_mutex_Seize (
> &the_networkSemaphore->Core_control.Mutex.Recursive,
> +   CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
> _Thread_Executing,
> true,   /* wait */
> _CORE_recursive_mutex_Seize_nested,
> @@ -412,6 +413,7 @@ rtems_bsdnet_semaphore_release (void)
> _ISR_lock_ISR_disable(&queue_context.Lock_context.Lock_context);
> status = _CORE_recursive_mutex_Surrender(
> &the_networkSemaphore->Core_control.Mutex.Recursive,
> +   CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
> _Thread_Executing,
> &queue_context
> );
> diff --git a/cpukit/posix/src/mutexlocksupp.c 
> b/cpukit/posix/src/mutexlocksupp.c
> index 1da6238..ea4c4e3 100644
> --- a/cpukit/posix/src/mutexlocksupp.c
> +++ b/cpukit/posix/src/mutexlocksupp.c
> @@ -76,7 +76,7 @@ int _POSIX_Mutex_Lock_support(
>);
>break;
>  case POSIX_MUTEX_NO_PROTOCOL:
> -  status = _CORE_recursive_mutex_Seize_no_protocol(
> +  status = _CORE_recursive_mutex_Seize(
>  &the_mutex->Mutex.Recursive,
>  POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
>  executing,
> @@ -89,6 +89,7 @@ int _POSIX_Mutex_Lock_support(
>_Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
>status = _CORE_recursive_mutex_Seize(
>  &the_mutex->Mutex.Recursive,
> +CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
>  executing,
>  wait,
>  _POSIX_Mutex_Lock_nested,
> diff --git a/cpukit/posix/src/mutexunlock.c b/cpukit/posix/src/mutexunlock.c
> index 3144314..c15f7e6 100644
> --- a/cpukit/posix/src/mutexunlock.c
> +++ b/cpukit/posix/src/mutexunlock.c
> @@ -53,7 +53,7 @@ int pthread_mutex_unlock(
>);
>break;
>  case POSIX_MUTEX_NO_PROTOCOL:
> -  status = _CORE_recursive_mutex_Surrender_no_protocol(
> +  status = _CORE_recursive_mutex_Surrender(
>  &the_mutex->Mutex.Recursive,
>  POSIX_MUTEX_NO_PROTOCOL_TQ_OPERATIONS,
>  executing,
> @@ -64,6 +64,7 @@ int pthread_mutex_unlock(
>_Assert( the_mutex->protocol == POSIX_MUTEX_PRIORITY_INHERIT );
>status = _CORE_recursive_mutex_Surrender(
>  &the_mutex->Mutex.Recursive,
> +CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
>  executing,
>  &queue_context
>);
> diff --git a/cpukit/rtems/src/semobtain.c b/cpukit/rtems/src/semobtain.c
> index 9afef54..b81612e 100644
> --- a/cpukit/rtems/src/semobtain.c
> +++ b/cpukit/rtems/src/semobtain.c
> @@ -75,6 +75,7 @@ rtems_status_code rtems_semaphore_obtain(
>  case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
>status = _CORE_recursive_mutex_Seize(
>  &the_semaphore->Core_control.Mutex.Recursive,
> +CORE_MUTEX_TQ_PRIORITY_INHERIT_OPERATIONS,
>  executing,
>  wait,
>  _CORE_recursive_mutex_Seize_nested,
> @@ -91,7 +92,7 @@ rtems_status_code rtems_semaphore_obtain(
>);
>break;
>  case SEMAPHORE_VARIANT_MUTEX_NO_PROTOCOL:
> -  status = _CORE_recursive_mutex_Seize_no_protocol(
> +  status = _CORE_recursive_mutex_Seize(
>  &the_semaphore->Core_control.Mutex.Recursive,
>  _Semaphore_Get_operations( the_semaphore ),
>  executing,
> diff --git a/cpukit/rtems/src/semrelease.c b/cpukit/rtems/src/semrelease.c
> index 39c467d..40860a1 100644
> --- a/cpukit/rtems/src/semrelease.c
> +++ b/cpukit/rtems/src/semrelease.c
> @@ -52,6 +52,7 @@ rtems_status_code rtems_semaphore_release( rtems_id id )
>  case SEMAPHORE_VARIANT_MUTEX_INHERIT_PRIORITY:
>status = 

Re: [PATCH] score: Unify CORE mutex seize/surrender

2016-09-27 Thread Sebastian Huber

On 27/09/16 16:59, Gedare Bloom wrote:

A mostly unrelated question: why do we have two different
_Semaphore_Get functions, one static in score/src/semaphore.c and the
other inlined from semimpl.h?


Yes, this is a bit confusing. One is part of the Classic API, the other 
is for the self-contained semaphores.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel