Commit Graph

1157 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
Sebastian Huber
090bdc7e94 posix: Fix use of uninitialized variable
Update #2859.
2017-01-25 11:45:49 +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
2b442a8e17 posix: fix typo in mmap arguments 2017-01-13 11:05:56 -05:00
Gedare Bloom
1ca8ee137e posix: add stub implementations for mman functions 2017-01-13 11:05:56 -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
Sebastian Huber
7c49927911 posix: Add pthread_getname_np(), ...
Add pthread_getname_np() and pthread_setname_np().

Update #2858.
2017-01-13 08:10:28 +01:00
Sebastian Huber
d063e7b3d8 score: Replace STATES_DELAYING
Replace STATES_DELAYING with STATES_WAITING_FOR_TIME.

There is no need for separate timeout thread states.  The
Thread_Control::Timer::header and Watchdog_Control::cpu members can be
used to figure out the kind of timeout.
2017-01-12 07:44:36 +01:00
Joel Sherrill
7a4b264574 Remove obsolete __RTEMS_HAVE_SYS_CPUSET_H__ 2017-01-11 09:45:32 -06:00
Joel Sherrill
ef362818df Add support for posix_devctl() 2017-01-11 09:45:32 -06:00
Sebastian Huber
5aa0fa1cec posix: Fix alarm() in SMP configurations
Avoid to change the CPU of the watchdog right in the middle of the
critical section.  This would corrupt the watchdog lock states.
2017-01-11 13:52:15 +01:00
Sebastian Huber
9a448aabe6 score: Add STATES_THREAD_QUEUE_WITH_IDENTIFIER
Add thread state bit to identify thread queues that are embedded in an
object with identifier.
2017-01-11 08:16:27 +01:00
Sebastian Huber
3a659b0481 score: Introduce _Internal_error() 2016-12-12 08:03:29 +01:00
Sebastian Huber
0a81a58254 Add INTERNAL_ERROR_POSIX_INIT_THREAD_CREATE_FAILED
Update #2825.
2016-12-12 08:03:29 +01:00
Sebastian Huber
b6606e8d99 score: Remove fatal is internal indicator
The fatal is internal indicator is redundant since the fatal source and
error code uniquely identify a fatal error.  Keep the fatal user
extension is internal parameter for backward compatibility and set it to
false always.

Update #2825.
2016-12-09 08:47:51 +01:00
Sebastian Huber
5b6c290ed0 score: Initialize thread queue context early
Initialize thread queue context early preferably outside the critical
section.

Remove implicit _Thread_queue_Context_initialize() from
_Thread_Wait_acquire().
2016-12-02 12:41:03 +01: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
620b23ece5 score: Optimize _Thread_queue_Enqueue()
Move thread state for _Thread_queue_Enqueue() to the thread queue
context.  This reduces the parameter count of _Thread_queue_Enqueue()
from five to four (ARM for example has only four function parameter
registers).  Since the thread state is used after several function calls
inside _Thread_queue_Enqueue() this parameter was saved on the stack
previously.
2016-11-24 08:46:20 +01:00
Sebastian Huber
d42cf3388e posix: Fix typo
Update #2674.
2016-11-23 15:12:28 +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
a4217c674d score: Rename _Thread_queue_Enqueue_critical()
Delete unused _Thread_queue_Enqueue() and rename
_Thread_queue_Enqueue_critical() to _Thread_queue_Enqueue().
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
d78d5294cd score: Add and use _Thread_Dispatch_direct()
This function is useful for operations which synchronously block, e.g.
self restart, self deletion, yield, sleep.  It helps to detect if these
operations are called in the wrong context.  Since the thread dispatch
necessary indicator is not used, this is more robust in some SMP
situations.

Update #2751.
2016-11-18 07:30:31 +01:00
Sebastian Huber
0e658d456c posix: Simplify cleanup push/pop
The POSIX cleanup list must be proteced from asynchronous thread
deletion.  Here local interrupt disable is sufficient.
2016-11-18 07:30:31 +01:00
Sebastian Huber
8b18b8eb67 posix: Fix _POSIX_RWLock_Manager_initialization()
Use right object class.
2016-11-04 10:54:52 +01:00
Sebastian Huber
2dd098a635 score: Introduce Thread_Scheduler_control::home
Replace Thread_Scheduler_control::control and
Thread_Scheduler_control::own_control with new
Thread_Scheduler_control::home.

Update #2556.
2016-11-02 10:05:45 +01:00
Sebastian Huber
bb9f09f34c posix: Fix timer interval
Do not overwrite timer interval with initial interval in
_POSIX_Timer_Insert().

Close #2798.
2016-10-31 13:09:56 +01:00
Sebastian Huber
3e9f4c9232 posix: Fix timeout handling in sigtimedwait()
Update #2798.
2016-10-31 13:09:50 +01:00
Sebastian Huber
8797c76add score: Unify CORE mutex seize/surrender
Use the Thread_Control::resource_count for the no protocol mutexes.
Merge the no protocol and priority inherit CORE mutex seize/surrender
operations.
2016-09-27 15:23:00 +02: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
b20b736382 score: Introduce _Thread_Get_priority()
Avoid direct access to thread internal data fields.
2016-09-08 09:55:28 +02:00
Sebastian Huber
15b5678dcd score: Move thread wait node to scheduler node
Update #2556.
2016-09-08 09:55:27 +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
709594f0fb posix: nanosleep: adjust elapsed time calculation
Use clock_gettime before and after sleep to calculate
the time spent asleep, and the amount of time remaining.

updates #2732
2016-08-10 12:09:50 -04:00
Sebastian Huber
aaaf9610db score: Add debug support to red-black trees
This helps to detect double insert and extract errors.
2016-08-08 09:34:29 +02:00
Sebastian Huber
2cb9b86e6a posix: Fix for RTEMS_DEBUG 2016-08-08 08:30:17 +02:00
Sebastian Huber
3b3552bf01 posix: Fix for RTEMS_DEBUG 2016-08-03 13:56:06 +02:00
Gedare Bloom
842005e432 posix: nanosleep: optimize away a time conversion
updates #2732
2016-07-29 13:13:41 -04:00
Sebastian Huber
1fcac5adc5 score: Turn thread lock into thread wait lock
The _Thread_Lock_acquire() function had a potentially infinite run-time
due to the lack of fairness at atomic operations level.

Update #2412.
Update #2556.
Update #2765.
2016-07-27 10:55:30 +02:00
Sebastian Huber
dfa2cdb15d posix: Fix error status 2016-07-27 09:09:53 +02:00
Gedare Bloom
39d97ab78c cpukit: refactor nanosleep and use 64-bit timeout for threadq
* Fixes a bug with elapsed time calculations misusing absolute time
  arguments in nanosleep_helper by passing the requested relative interval.
* Fixes a bug with truncation of absolute timeouts by passing the
  full 64-bit value to Thread_queue_Enqueue.
* Share yield logic between nanosleep and clock_nanosleep.

updates #2732
2016-07-26 14:13:36 -04:00
Gedare Bloom
e0f17fcf6f posix: fix clock_nanosleep and nanosleep clock use
Sleeping with CLOCK_REALTIME should use the WATCHDOG_ABSOLUTE
clock discipline for the threadq so that the timeout interval
may change in case the clock source changes. Similarly,
CLOCK_MONOTONIC uses the WATCHDOG_RELATIVE threadq that will
only wakeup the thread after the requested count of ticks elapse.

updates #2732
2016-07-25 12:44:48 -04: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