pthread: restore pthread mutex default protocol POSIX compatibility
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
5a0ab205ca
commit
2447b7bd9a
24 changed files with 63 additions and 22 deletions
|
@ -120,6 +120,7 @@ CONFIG_PRIORITY_INHERITANCE=y
|
|||
CONFIG_PSEUDOTERM=y
|
||||
CONFIG_PTABLE_PARTITION=y
|
||||
CONFIG_PTHREAD_CLEANUP=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_PTHREAD_STACK_MIN=1024
|
||||
CONFIG_RAM_SIZE=1048576
|
||||
|
|
|
@ -67,6 +67,7 @@ CONFIG_NSH_LINELEN=64
|
|||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=2048
|
||||
CONFIG_RAM_SIZE=524288
|
||||
CONFIG_RAM_START=0x34000000
|
||||
|
|
|
@ -62,6 +62,7 @@ CONFIG_NSH_READLINE=y
|
|||
CONFIG_PREALLOC_CHILDSTATUS=2
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_RAM_SIZE=262144
|
||||
CONFIG_RAM_START=0x1fff0000
|
||||
CONFIG_RAW_BINARY=y
|
||||
|
|
|
@ -75,6 +75,7 @@ CONFIG_NSH_STRERROR=y
|
|||
CONFIG_PREALLOC_CHILDSTATUS=2
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PWM=y
|
||||
CONFIG_RAM_SIZE=262144
|
||||
CONFIG_RAM_START=0x1fff0000
|
||||
|
|
|
@ -133,6 +133,7 @@ CONFIG_PRIORITY_INHERITANCE=y
|
|||
CONFIG_PSEUDOTERM=y
|
||||
CONFIG_PTABLE_PARTITION=y
|
||||
CONFIG_PTHREAD_CLEANUP=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_PTHREAD_STACK_MIN=1024
|
||||
CONFIG_RAM_SIZE=65536
|
||||
|
|
|
@ -30,6 +30,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
|||
CONFIG_NSH_LINELEN=64
|
||||
CONFIG_NSH_READLINE=y
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_RAM_SIZE=98304
|
||||
CONFIG_RAM_START=0x20000000
|
||||
CONFIG_RAW_BINARY=y
|
||||
|
|
|
@ -66,6 +66,7 @@ CONFIG_NSH_NESTDEPTH=0
|
|||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
||||
CONFIG_PREALLOC_TIMERS=2
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=464
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
|
|
|
@ -84,6 +84,7 @@ CONFIG_NSH_LINELEN=40
|
|||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
||||
CONFIG_PREALLOC_TIMERS=2
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=464
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
|
|
|
@ -72,6 +72,7 @@ CONFIG_NSH_LINELEN=40
|
|||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
||||
CONFIG_PREALLOC_TIMERS=2
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=464
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
|
|
|
@ -49,6 +49,7 @@ CONFIG_NSH_NESTDEPTH=0
|
|||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
||||
CONFIG_PREALLOC_TIMERS=2
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=464
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
|
|
|
@ -44,6 +44,7 @@ CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=5
|
|||
CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=768
|
||||
CONFIG_PREALLOC_TIMERS=2
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=464
|
||||
CONFIG_RAM_SIZE=20480
|
||||
CONFIG_RAM_START=0x20000000
|
||||
|
|
|
@ -39,6 +39,7 @@ CONFIG_NSH_READLINE=y
|
|||
CONFIG_NUCLEO_CONSOLE_VIRTUAL=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_RAM_SIZE=245760
|
||||
CONFIG_RAM_START=0x20010000
|
||||
CONFIG_RAW_BINARY=y
|
||||
|
|
|
@ -74,6 +74,7 @@ CONFIG_NUCLEO_CONSOLE_VIRTUAL=y
|
|||
CONFIG_PIPES=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PWM=y
|
||||
CONFIG_PWM_MULTICHAN=y
|
||||
CONFIG_PWM_NCHANNELS=4
|
||||
|
|
|
@ -40,6 +40,7 @@ CONFIG_NSH_READLINE=y
|
|||
CONFIG_NUCLEO_CONSOLE_VIRTUAL=y
|
||||
CONFIG_PREALLOC_TIMERS=4
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_RAM_SIZE=245760
|
||||
CONFIG_RAM_START=0x20010000
|
||||
CONFIG_RAW_BINARY=y
|
||||
|
|
|
@ -40,6 +40,7 @@ CONFIG_NSH_DISABLE_IFCONFIG=y
|
|||
CONFIG_NSH_DISABLE_IFUPDOWN=y
|
||||
CONFIG_PREALLOC_CHILDSTATUS=16
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=4194304
|
||||
CONFIG_PTHREAD_STACK_MIN=4194304
|
||||
|
|
|
@ -32,6 +32,7 @@ CONFIG_INIT_STACKSIZE=4194304
|
|||
CONFIG_LIBM=y
|
||||
CONFIG_PREALLOC_CHILDSTATUS=16
|
||||
CONFIG_PRIORITY_INHERITANCE=y
|
||||
CONFIG_PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT=y
|
||||
CONFIG_PTHREAD_MUTEX_TYPES=y
|
||||
CONFIG_PTHREAD_STACK_DEFAULT=4194304
|
||||
CONFIG_PTHREAD_STACK_MIN=4194304
|
||||
|
|
|
@ -59,7 +59,7 @@ int pthread_mutexattr_getprotocol(FAR const pthread_mutexattr_t *attr,
|
|||
#else
|
||||
linfo("Returning %d\n", PTHREAD_PRIO_NONE);
|
||||
*protocol = PTHREAD_PRIO_NONE;
|
||||
#endif
|
||||
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -63,8 +63,12 @@ int pthread_mutexattr_init(FAR pthread_mutexattr_t *attr)
|
|||
attr->pshared = 0;
|
||||
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
attr->proto = SEM_PRIO_INHERIT;
|
||||
#endif
|
||||
# ifdef PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT
|
||||
attr->proto = PTHREAD_PRIO_INHERIT;
|
||||
# else
|
||||
attr->proto = PTHREAD_PRIO_NONE;
|
||||
# endif
|
||||
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||
|
||||
#ifdef CONFIG_PTHREAD_MUTEX_TYPES
|
||||
attr->type = PTHREAD_MUTEX_DEFAULT;
|
||||
|
|
|
@ -54,21 +54,21 @@ int pthread_mutexattr_setprotocol(FAR pthread_mutexattr_t *attr,
|
|||
linfo("attr=0x%p protocol=%d\n", attr, protocol);
|
||||
DEBUGASSERT(attr != NULL);
|
||||
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
if (protocol >= PTHREAD_PRIO_NONE && protocol <= PTHREAD_PRIO_PROTECT)
|
||||
{
|
||||
attr->proto = protocol;
|
||||
return OK;
|
||||
switch (protocol)
|
||||
{
|
||||
case PTHREAD_PRIO_NONE:
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
case PTHREAD_PRIO_INHERIT:
|
||||
attr->proto = protocol;
|
||||
#endif /* CONFIG_PRIORITY_INHERITANCE */
|
||||
return OK;
|
||||
|
||||
default:
|
||||
return ENOTSUP;
|
||||
}
|
||||
}
|
||||
|
||||
return EINVAL;
|
||||
|
||||
#else
|
||||
if (protocol == PTHREAD_PRIO_NONE)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
return EINVAL;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
*
|
||||
* Returned Value:
|
||||
* This function is exposed as a non-standard application interface. It
|
||||
* returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and
|
||||
* the errno value is set appropriately.
|
||||
* returns zero (OK). Otherwise, an error code.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
|
@ -67,8 +67,9 @@
|
|||
*
|
||||
* Returned Value:
|
||||
* This function is exposed as a non-standard application interface. It
|
||||
* returns zero (OK) if successful. Otherwise, -1 (ERROR) is returned and
|
||||
* the errno value is set appropriately.
|
||||
* returns zero (OK) if successful. Otherwise, -EINVAL is returned if the
|
||||
* value specified by protocol is invalid or -ENOTSUP if the value
|
||||
* specified by protocol is an unsupported value.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -83,8 +84,7 @@ int nxsem_set_protocol(FAR sem_t *sem, int protocol)
|
|||
|
||||
case SEM_PRIO_INHERIT:
|
||||
case SEM_PRIO_PROTECT:
|
||||
return -ENOSYS;
|
||||
break;
|
||||
return -ENOTSUP;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -658,6 +658,24 @@ config PTHREAD_MUTEX_DEFAULT_UNSAFE
|
|||
|
||||
endchoice # Default NORMAL mutex robustness
|
||||
|
||||
choice
|
||||
prompt "Default pthread mutex protocol"
|
||||
default PTHREAD_MUTEX_DEFAULT_PRIO_NONE
|
||||
|
||||
config PTHREAD_MUTEX_DEFAULT_PRIO_NONE
|
||||
bool "PTHREAD_PRIO_NONE default"
|
||||
---help---
|
||||
By default, pthread mutexes utilize PTHREAD_PRIO_NONE protocol (standard).
|
||||
|
||||
config PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT
|
||||
bool "PTHREAD_PRIO_INHERIT default"
|
||||
depends on PRIORITY_INHERITANCE
|
||||
---help---
|
||||
By default, pthread mutexes utilize PTHREAD_PRIO_INHERIT protocol
|
||||
(POSIX non-standard but a reasonable choice for most real-time systems).
|
||||
|
||||
endchoice # Default pthread mutex protocol
|
||||
|
||||
config PTHREAD_CLEANUP
|
||||
bool "pthread cleanup stack"
|
||||
default n
|
||||
|
|
|
@ -61,7 +61,11 @@ int pthread_mutex_init(FAR pthread_mutex_t *mutex,
|
|||
uint8_t type = PTHREAD_MUTEX_DEFAULT;
|
||||
#endif
|
||||
#ifdef CONFIG_PRIORITY_INHERITANCE
|
||||
# ifdef PTHREAD_MUTEX_DEFAULT_PRIO_INHERIT
|
||||
uint8_t proto = PTHREAD_PRIO_INHERIT;
|
||||
# else
|
||||
uint8_t proto = PTHREAD_PRIO_NONE;
|
||||
# endif
|
||||
#endif
|
||||
#ifndef CONFIG_PTHREAD_MUTEX_UNSAFE
|
||||
#ifdef CONFIG_PTHREAD_MUTEX_DEFAULT_UNSAFE
|
||||
|
|
|
@ -100,7 +100,7 @@ int nxsem_set_protocol(FAR sem_t *sem, int protocol)
|
|||
|
||||
/* Not yet supported */
|
||||
|
||||
return -ENOSYS;
|
||||
return -ENOTSUP;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue