Commit Graph

368 Commits

Author SHA1 Message Date
Sebastian Huber
e366f774a7 score: Add _Thread_queue_Object_name
Add the special thread queue name _Thread_queue_Object_name to mark
thread queues embedded in an object with identifier.  Using the special
thread state STATES_THREAD_QUEUE_WITH_IDENTIFIER is not reliable for
this purpose since the thread wait information and thread state are
protected by different SMP locks in separate critical sections.  Remove
STATES_THREAD_QUEUE_WITH_IDENTIFIER.

Add and use _Thread_queue_Object_initialize().

Update #2858.
2017-01-31 09:38:07 +01:00
Gedare Bloom
ba77628250 posix: shared memory support
Add POSIX shared memory manager (Shm). Includes a hook-based
approach for the backing memory storage that defaults to the
Workspace, and a test is provided using the heap. A test is
also provided for the basic use of mmap'ing a shared memory
object. This test currently fails at the mmap stage due to
no support for mmap.
2017-01-13 11:17:30 -05:00
Gedare Bloom
e7eeb38d23 posix: move sys/mman.h to newlib and test it in psxhdrs 2017-01-13 11:05:56 -05:00
Sebastian Huber
4a03e75218 configure: Remove SIZEOF_PTHREAD_SPINLOCK_T 2017-01-13 09:45:59 +01:00
Sebastian Huber
544b59bf47 configure: Remove HAVE_SEMAPHORE_H support 2017-01-13 09:35:01 +01:00
Joel Sherrill
7a4b264574 Remove obsolete __RTEMS_HAVE_SYS_CPUSET_H__ 2017-01-11 09:45:32 -06:00
Sebastian Huber
6cc83b3217 posix: Fix typo 2016-12-02 12:40:32 +01:00
Sebastian Huber
aadd318cd9 posix: Fix fall back spinlock implementation
Update #2674.
2016-12-02 09:56:40 +01:00
Sebastian Huber
c09db57f37 score: Fix thread queue context initialization
Initialize the thread queue context with invalid data in debug
configurations to catch missing set up steps.
2016-11-28 16:08:43 +01:00
Sebastian Huber
c42be504c9 posix: Add self-contained pthread spinlock
Turn pthread_spinlock_t into a self-contained object.  On uni-processor
configurations, interrupts are disabled in the lock/trylock operations
and the previous interrupt status is restored in the corresponding
unlock operations.  On SMP configurations, a ticket lock is a acquired
and released in addition.

The self-contained pthread_spinlock_t object is defined by Newlib in
<sys/_pthreadtypes.h>.

typedef struct {
  struct _Ticket_lock_Control _lock;
  __uint32_t                  _interrupt_state;
} pthread_spinlock_t;

This implementation is simple and efficient.  However, this test case of
the Linux Test Project would fail due to call of printf() and sleep()
during spin lock ownership:

https://github.com/linux-test-project/ltp/blob/master/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/1-2.c

There is only limited support for profiling on SMP configurations.

Delete CORE spinlock implementation.

Update #2674.
2016-11-23 12:52:06 +01:00
Sebastian Huber
125f248231 score: Add thread queue enqueue callout
Replace the expected thread dispatch disable level with a thread queue
enqueue callout.  This enables the use of _Thread_Dispatch_direct() in
the thread queue enqueue procedure.  This avoids impossible exection
paths, e.g. Per_CPU_Control::dispatch_necessary is always true.
2016-11-23 12:52:06 +01:00
Sebastian Huber
300f6a481a score: Rework thread priority management
Add priority nodes which contribute to the overall thread priority.

The actual priority of a thread is now an aggregation of priority nodes.
The thread priority aggregation for the home scheduler instance of a
thread consists of at least one priority node, which is normally the
real priority of the thread.  The locking protocols (e.g. priority
ceiling and priority inheritance), rate-monotonic period objects and the
POSIX sporadic server add, change and remove priority nodes.

A thread changes its priority now immediately, e.g. priority changes are
not deferred until the thread releases its last resource.

Replace the _Thread_Change_priority() function with

 * _Thread_Priority_perform_actions(),
 * _Thread_Priority_add(),
 * _Thread_Priority_remove(),
 * _Thread_Priority_change(), and
 * _Thread_Priority_update().

Update #2412.
Update #2556.
2016-09-21 08:59:26 +02:00
Sebastian Huber
e41308eab8 score: Introduce Thread_queue_Lock_context
Introduce Thread_queue_Lock_context to contain the context necessary for
thread queue lock and thread wait lock acquire/release operations to
reduce the Thread_Control size.
2016-09-08 09:55:27 +02:00
Sebastian Huber
114e40880b score: Simplify thread queue acquire/release 2016-09-08 09:55:26 +02:00
Sebastian Huber
db56369883 score: Fix warning 2016-09-08 09:55:26 +02:00
Gedare Bloom
b5bfaaf9c2 posix: cond_timedwait remember and use clock from condattr
updates #2745
2016-07-25 12:44:47 -04:00
Gedare Bloom
127c20ebd7 posix: refactor cond wait support to defer abstime conversion
updates #2745
2016-07-25 12:44:47 -04:00
Sebastian Huber
254dc82daf score: Change Priority_Control to 64-bit
A 32-bit Priority_Control limits the uptime to 49 days with a 1ms clock
tick in case the EDF scheduler is used.  Increase it to 64-bit to enable
proper operation of the EDF scheduler,

Close 2173.
2016-06-24 14:44:31 +02:00
Sebastian Huber
77ff5599e0 score: Introduce map priority scheduler operation
Introduce map/unmap priority scheduler operations to map thread priority
values from/to the user domain to/from the scheduler domain.  Use the
map priority operation to validate the thread priority.  The EDF
schedulers use this new operation to distinguish between normal
priorities and priorities obtain through a job release.

Update #2173.
Update #2556.
2016-06-22 14:36:40 +02:00
Sebastian Huber
1a4eac500c posix: Generalize _POSIX_Priority_To_core()
Move POSIX API priority validation into _POSIX_Priority_To_core().
2016-06-22 14:00:28 +02:00
Sebastian Huber
5a32c486f9 posix: Make POSIX API aware of scheduler instances 2016-06-22 14:00:28 +02:00
Sebastian Huber
eec08efc90 posix: Rework sporadic server scheduling policy
Instead of lowering the priority in case the initial budget is consumed
raise the priority for each new period.  Restore the normal priority
once the initial budget is consumed.  This makes it later easier to
combine the high priority phase with temporary priority boosts (e.g. via
priority ceiling and inheritance).

Use the thread lock to protect the POSIX thread attributes instead of
the thread state lock.  This makes it easier to change the thread
priority and keep the POSIX attributes consistent.

Fixes a false positive use of uninitialized variable warning.
2016-06-22 14:00:28 +02:00
Sebastian Huber
6bab009a61 posix: Delete POSIX_API_Control::schedparam
This field was redundant.
2016-06-22 14:00:28 +02:00
Sebastian Huber
4dc5450eeb posix: Delete POSIX_API_Control::schedpolicy
This field was redundant.
2016-06-22 14:00:28 +02:00
Sebastian Huber
4da078a8ad posix: Delete POSIX_API_Control::ss_high_priority
This field was unused.
2016-06-22 14:00:27 +02:00
Sebastian Huber
2df7fcff88 posix: _POSIX_Mutex_Default_attributes
Make _POSIX_Mutex_Default_attributes constant and independent of the
scheduler instance.  Use INT_MAX to indicate the default ceiling
priority.
2016-06-22 14:00:27 +02:00
Sebastian Huber
917884c408 posix: Fix poradic server initial CPU budget
Update #2738.
2016-06-15 10:43:34 +02:00
Sebastian Huber
5d65d0ddaf posix: Use _POSIX_Threads_Sporadic_timer_insert() 2016-06-15 08:55:18 +02:00
Sebastian Huber
d07f582565 posix: Remove superfluous code
Remove double declarations, useless comments and unused functions.
2016-06-15 08:05:35 +02:00
Sebastian Huber
5a598ac99b score: Add CORE mutex variants
Add CORE_recursive_mutex_Control and CORE_ceiling_mutex_Control to avoid
the run-time evaluation of attributes to figure out how a particular
mutex methods should behave.  Start with the no protocol variants.  This
eliminates the CORE_MUTEX_DISCIPLINES_FIFO and
CORE_MUTEX_DISCIPLINES_PRIORITY disciplines.
2016-05-30 16:16:23 +02:00
Sebastian Huber
bbb3c5f331 posix: Delete POSIX_Mutex_Protocol::process_shared 2016-05-30 16:16:23 +02:00
Sebastian Huber
2581a563f9 score: Add semaphore variants 2016-05-30 16:16:21 +02:00
Sebastian Huber
93306058c0 score: _CORE_mutex_Check_dispatch_for_seize()
Move the safety check performed by
_CORE_mutex_Check_dispatch_for_seize() out of the performance critical
path and generalize it.  Blocking on a thread queue with an unexpected
thread dispatch disabled level is illegal in all system states.

Add the expected thread dispatch disable level (which may be 1 or 2
depending on the operation) to Thread_queue_Context and use it in
_Thread_queue_Enqueue_critical().
2016-05-30 16:16:21 +02:00
Sebastian Huber
0e1d11f3f0 score: Add _Thread_queue_Context_set_MP_callout()
Add _Thread_queue_Context_set_MP_callout() to simplify
_Thread_queue_Context_initialize().  This makes it possible to more
easily add additional fields to Thread_queue_Context.
2016-05-30 16:16:21 +02:00
Sebastian Huber
dce487912d score: Add Status_Control for all APIs
Unify the status codes of the Classic and POSIX API to use the new enum
Status_Control.  This eliminates the Thread_Control::Wait::timeout_code
field and the timeout parameter of _Thread_queue_Enqueue_critical() and
_MPCI_Send_request_packet().  It gets rid of the status code translation
tables and instead uses simple bit operations to get the status for a
particular API.  This enables translation of status code constants at
compile time.  Add _Thread_Wait_get_status() to avoid direct access of
thread internal data structures.
2016-05-26 21:44:31 +02:00
Sebastian Huber
631b3c8967 score: Move thread queue MP callout to context
Drop the multiprocessing (MP) dependent callout parameter from the
thread queue extract, dequeue, flush and unblock methods.  Merge this
parameter with the lock context into new structure Thread_queue_Context.
This helps to gets rid of the conditionally compiled method call
helpers.
2016-05-25 12:43:54 +02:00
Sebastian Huber
e266d134eb Replace *_Get_interrupt_disable() with *_Get()
Uniformly use *_Get() to get an object by identifier with a lock
context.
2016-05-20 16:17:00 +02:00
Sebastian Huber
582bb23c74 score: Rename _Objects_Get_local()
Rename _Objects_Get_local() into _Objects_Get().  Confusions with the
previous _Objects_Get() function are avoided since the Objects_Locations
parameter is gone.
2016-05-20 16:17:00 +02:00
Sebastian Huber
0cc60718d0 posix: Add const to _POSIX_Keys_Key_value_find() 2016-05-20 16:16:59 +02:00
Sebastian Huber
05f9b02e3c posix: Add and use _POSIX_Get_object_body() 2016-05-20 16:16:26 +02:00
Sebastian Huber
7dfb4b970c score: Add per scheduler instance maximum priority
The priority values are only valid within a scheduler instance.  Thus,
the maximum priority value must be defined per scheduler instance.  The
first scheduler instance defines PRIORITY_MAXIMUM.  This implies that
RTEMS_MAXIMUM_PRIORITY and POSIX_SCHEDULER_MAXIMUM_PRIORITY are only
valid for threads of the first scheduler instance.  Further
API/implementation changes are necessary to fix this.

Update #2556.
2016-05-20 16:11:02 +02:00
Sebastian Huber
da82656065 posix: Rework thread cancellation
Add Thread_Life_state::THREAD_LIFE_CHANGE_DEFERRED and rework the POSIX
thread cancellation to use the thread life states.

Update #2555.
Update #2626.
2016-05-20 07:49:39 +02:00
Sebastian Huber
54550e048d posix: Rework pthread_join()
Rework pthread_join() to use _Thread_Join().

Close #2402.
Update #2555.
Update #2626.
Close #2714.
2016-05-20 07:49:39 +02:00
Sebastian Huber
8bc6bf28aa posix: Avoid Giant lock for some pthread functions
Avoid Giant lock for pthread_getattr_np(), pthread_setschedparam() and
pthread_getschedparam().  Replace POSIX threads scheduler lock with
thread state lock.

Update #2555.
2016-05-12 13:24:41 +02:00
Sebastian Huber
d9bb9ebc34 posix: Make _POSIX_signals_Action_handler() static 2016-05-12 13:20:34 +02:00
Sebastian Huber
0a68d8e45a score: Optimize _Objects_Get_local()
Make the interrupt lock context the second parameter to avoid register
moves.
2016-05-02 13:46:50 +02:00
Sebastian Huber
c8982e5f6a posix: Simplify message queues
The mq_open() function returns a descriptor to a POSIX message queue
object identified by a name.  This is similar to sem_open().  In
contrast to the POSIX semaphore the POSIX message queues use a separate
object for the descriptor.  This extra object is superfluous, since the
object identifier can be used directly for this purpose, just like for
the semaphores.

Update #2702.
Update #2555.
2016-05-02 07:46:15 +02:00
Sebastian Huber
dd6c28eee0 posix: Delete POSIX_Message_queue_Control::named
Delete unused POSIX_Message_queue_Control::named.
2016-05-02 07:46:14 +02:00
Sebastian Huber
49c293f492 posix: POSIX_Message_queue_Control::process_shared
Delete unused POSIX_Message_queue_Control::process_shared.
2016-05-02 07:46:13 +02:00
Sebastian Huber
3e36a16774 posix: _POSIX_Message_queue_Create_support()
Make  _POSIX_Message_queue_Create_support() static since it is only used
by mq_open().
2016-05-02 07:46:13 +02:00