Commit Graph

913 Commits

Author SHA1 Message Date
Sebastian Huber
8ce00eaf48 posix: Delete unused _POSIX_Threads_Get()
Close #1759.
2014-12-18 10:48:35 +01:00
Sebastian Huber
172e953147 posix: Delete key/value if value is set to NULL 2014-12-12 13:16:25 +01:00
Sebastian Huber
dac340dd66 posix: Simplify _POSIX_Keys_Find() 2014-12-12 13:16:03 +01:00
Josh Oguin
e106aa7380 cpukit/posix/src/timertsr.c: Add _Assert()
CodeSonar flagged this as an empty if body. Upon analysis, it turned
out to be an error that we think should never occur but if it did,
there is nothing we could do about it. It would likely just indicate
the thread was deleted before we got here. Adding the _Assert() at least
will flag this if it ever occurs during a debug build and we can discuss
what happened.
2014-11-26 07:51:59 -06:00
Joel Sherrill
287843f14c sys/mman.h: New file. Clean up and add supporting stubs
* Makefile.am updated and preinstall.am regenerated.
	* mprotect.c had a prototype removed now that we have mman.h
	* mmap.c, munmap.c: New stub files.
2014-11-20 12:57:33 -06:00
Sebastian Huber
a38ced2683 score: Rework global construction
Ensure that the global construction is performed in the context of the
first initialization thread.  On SMP this was not guaranteed in the
previous implementation.
2014-10-13 14:30:22 +02:00
Sebastian Huber
b9f952254b posix: Add auto initializaton for rwlock 2014-10-08 11:26:27 +02:00
Sebastian Huber
dfdad6ab1d posix: Fix mutex auto initialization
Use the once lock to prevent race conditions during auto initialization.
2014-10-08 11:26:27 +02:00
Sebastian Huber
419accf6a6 posix: Use function instead of macros 2014-10-08 11:26:26 +02:00
Sebastian Huber
05ac47d75e posix: Use RTEMS_DECONST() 2014-09-08 07:53:02 +02:00
Sebastian Huber
4d5250c165 posix: Fix warning 2014-09-08 07:53:02 +02:00
Joel Sherrill
9d95ef9cef mprotect.c: Remove warning for no prototype 2014-09-04 09:08:04 -05:00
Chris Johns
59990cc975 Regenerate all preinstall.am files.
With this patch the preinstall.am files are in a set order and not
dependent on now perl implements a hash.
2014-08-29 12:48:01 +10:00
Joel Sherrill
b597c0d60c Regenerate all preinstall.am files.
Apparently, at some point automake output changed and these were
not updated.
2014-08-28 08:44:52 -05:00
Sebastian Huber
390cfcda71 posix: Simplify key implementation 2014-08-05 09:30:37 +02:00
Sebastian Huber
60fe374247 rbtree: Add and use RBTree_Compare_result 2014-08-05 09:30:37 +02:00
Sebastian Huber
40dcafaf80 Add and use RTEMS_CONTAINER_OF() 2014-08-05 09:30:33 +02:00
Sebastian Huber
4cd55724bb Delete unused *_Is_null() functions 2014-07-26 12:52:22 +02:00
Joel Sherrill
875fff0ae3 Add _TOD_Adjust to SCORE TOD Handler.
This lays the proper structure for doing future work on
time adjustment algorithms. Any TOD adjustments should be
requested at the API level and performed at the SCORE level.

Additionally updated a test.
2014-07-23 16:53:24 -05:00
Joel Sherrill
3b6352d2e6 adjtime.c: Use timestamp math and simplify 2014-07-23 14:24:49 -05:00
Sebastian Huber
64939bc9ef rbtree: Reduce RBTree_Control size
Remove compare function and is unique indicator from the control
structure.  Rename RBTree_Compare_function to RBTree_Compare.  Rename
rtems_rbtree_compare_function to rtems_rbtree_compare.  Provide C++
compatible initializers.  Add compare function and is unique indicator
to _RBTree_Find(), _RBTree_Insert(), rtems_rbtree_find() and
rtems_rbtree_insert().  Remove _RBTree_Is_unique() and
rtems_rbtree_is_unique().  Remove compare function and is unique
indicator from _RBTree_Initialize_empty() and
rtems_rbtree_initialize_empty().
2014-07-15 10:03:48 -05:00
Sebastian Huber
f6b7b7ba0a score: Fix _Thread_Delay_ended() on SMP
Suppose we have two tasks A and B and two processors.  Task A is about
to delete task B.  Now task B calls rtems_task_wake_after(1) on the
other processor.  Task B will block on the Giant lock.  Task A
progresses with the task B deletion until it has to wait for
termination.  Now task B obtains the Giant lock, sets its state to
STATES_DELAYING, initializes its watchdog timer and waits.  Eventually
_Thread_Delay_ended() is called, but now _Thread_Get() returned NULL
since the thread is already marked as deleted.  Thus task B remained
forever in the STATES_DELAYING state.

Instead of passing the thread identifier use the thread control block
directly via the watchdog user argument.  This makes
_Thread_Delay_ended() also a bit more efficient.
2014-06-20 08:24:46 +02:00
Sebastian Huber
701dd96f59 score: PR2181: Add _Thread_Yield()
The _Scheduler_Yield() was called by the executing thread with thread
dispatching disabled and interrupts enabled.  The rtems_task_suspend()
is explicitly allowed in ISRs:

http://rtems.org/onlinedocs/doc-current/share/rtems/html/c_user/Interrupt-Manager-Directives-Allowed-from-an-ISR.html#Interrupt-Manager-Directives-Allowed-from-an-ISR

Unlike the other scheduler operations the locking was performed inside
the operation.  This lead to the following race condition.  Suppose a
ISR suspends the executing thread right before the yield scheduler
operation.  Now the executing thread is not longer in the set of ready
threads.  The typical scheduler operations did not check the thread
state and will now extract the thread again and enqueue it.  This
corrupted data structures.

Add _Thread_Yield() and do the scheduler yield operation with interrupts
disabled.  This has a negligible effect on the interrupt latency.
2014-06-12 16:13:26 +02:00
Sebastian Huber
6c7caa1a9e score: Add and use _Thread_Owns_resources() 2014-06-03 08:15:16 +02:00
Sebastian Huber
a92c4882bb score: _Scheduler_Get_affinity()
Drop scheduler parameter.  Coding style.
2014-06-02 08:28:42 +02:00
Sebastian Huber
f39f667a69 score: Simplify _Thread_Change_priority()
The function to change a thread priority was too complex.  Simplify it
with a new scheduler operation.  This increases the average case
performance due to the simplified logic.  The interrupt disabled
critical section is a bit prolonged since now the extract, update and
enqueue steps are executed atomically.  This should however not impact
the worst-case interrupt latency since at least for the Deterministic
Priority Scheduler this sequence can be carried out with a wee bit of
instructions and no loops.

Add _Scheduler_Change_priority() to replace the sequence of
  - _Thread_Set_transient(),
  - _Scheduler_Extract(),
  - _Scheduler_Enqueue(), and
  - _Scheduler_Enqueue_first().

Delete STATES_TRANSIENT, _States_Is_transient() and
_Thread_Set_transient() since this state is now superfluous.

With this change it is possible to get rid of the
SCHEDULER_SMP_NODE_IN_THE_AIR state.  This considerably simplifies the
implementation of the new SMP locking protocols.
2014-05-15 12:18:44 +02:00
Sebastian Huber
7d1436e4b3 posix: Fix POSIX keys initialization
Always initialize the freechain.  This prevents a NULL pointer access in
case no initial key value pairs are defined.
2014-05-06 13:46:20 +02:00
Sebastian Huber
c5831a3f9a score: Add clustered/partitioned scheduling
Clustered/partitioned scheduling helps to control the worst-case
latencies in the system.  The goal is to reduce the amount of shared
state in the system and thus prevention of lock contention.  Modern
multi-processor systems tend to have several layers of data and
instruction caches.  With clustered/partitioned scheduling it is
possible to honour the cache topology of a system and thus avoid
expensive cache synchronization traffic.

We have clustered scheduling in case the set of processors of a system
is partitioned into non-empty pairwise-disjoint subsets.  These subsets
are called clusters.  Clusters with a cardinality of one are partitions.
Each cluster is owned by exactly one scheduler instance.
2014-04-15 10:41:44 +02:00
Sebastian Huber
69aa33490b score: Simplify thread control initialization
The thread control block contains fields that point to application
configuration dependent memory areas, like the scheduler information,
the API control blocks, the user extension context table, the RTEMS
notepads and the Newlib re-entrancy support.  Account for these areas in
the configuration and avoid extra workspace allocations for these areas.

This helps also to avoid heap fragementation and reduces the per thread
memory due to a reduced heap allocation overhead.
2014-04-15 08:37:12 +02:00
Sebastian Huber
57c29858ce score: Lazy key value pair allocation 2014-04-07 14:51:31 +02:00
Sebastian Huber
e785fbaae5 score: Delete _Thread_Ticks_per_timeslice
Use the Configuration instead.
2014-04-07 14:51:31 +02:00
Sebastian Huber
24934e36e2 score: Add scheduler control to scheduler ops
Scheduler operations must be free of a global scheduler context to
enable partitioned/clustered scheduling.
2014-04-04 11:01:18 +02:00
Joel Sherrill
69d7279bd5 pthreadimpl.h: Conditionalize thread affinity copying 2014-04-03 17:02:40 -05:00
Joel Sherrill
68c156aea7 pthreadcreate.c: Fix bug where attr used instead of the_attr 2014-04-03 15:03:42 -05:00
Joel Sherrill
a0a073d1c9 pthread.c: Conditionalize thread affinity initialization 2014-04-03 13:51:47 -05:00
Jennifer Averett
e045fb6c60 posix: Move affinity from thread to scheduler. 2014-04-03 10:48:57 -05:00
Jennifer Averett
7205189ce3 posix: Modified pthread init to use cpuset default. 2014-04-03 10:48:57 -05:00
Sebastian Huber
03e8928753 score: Delete CORE_mutex_Control::lock
The holder field is enough to determine if a mutex is locked or not.

This leads also to better error status codes in case a
rtems_semaphore_release() is done for a mutex without having the
ownership.
2014-03-31 10:14:42 +02:00
Sebastian Huber
23fec9f0e1 score: PR2152: Use allocator mutex for objects
Use allocator mutex for objects allocate/free.  This prevents that the
thread dispatch latency depends on the workspace/heap fragmentation.
2014-03-31 08:29:44 +02:00
Sebastian Huber
fb7199d3a2 score: Relax Giant lock usage for API mutexes
It is no longer necessary to protect the workspace allocations with the
Giant lock due to the thread life cycle re-implementation.
2014-03-31 08:29:43 +02:00
Sebastian Huber
1b1be254e7 score: Thread life cycle re-implementation
The thread deletion is now supported on SMP.

This change fixes the following PRs:

PR1814: SMP race condition between stack free and dispatch

PR2035: psxcancel reveals NULL pointer access in _Thread_queue_Extract()

The POSIX cleanup handler are now called in the right context (should be
called in the context of the terminating thread).

http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_09.html

Add a user extension the reflects a thread termination event.  This is
used to reclaim the Newlib reentrancy structure (may use file
operations), the POSIX cleanup handlers and the POSIX key destructors.
2014-03-31 08:29:43 +02:00
Sebastian Huber
391ad3ee4f score: Fix thread restart extensions context
Run the thread restart extensions in the context of the restarted
thread.  Run them with thread dispatching enabled.
2014-03-31 08:29:43 +02:00
Sebastian Huber
fc521e2df6 posix: Use thread action for signals 2014-03-31 08:29:43 +02:00
Christian Mauderer
01f2337432 posix: Prevent pthread_setspecific from returning EAGAIN.
The man-page for pthread_setspecific does not define the EAGAIN return value.
Further without this patch it was not possible to set keys that have been
already set a new value.

Add test for setting a new value to a already set key.
2014-03-24 08:31:49 +01:00
Christian Mauderer
a5385b1f72 score: Unify pthread and gxx_wrapper once and move to score. 2014-03-21 11:21:49 +01:00
Chris Johns
c49985691f Change all references of rtems.com to rtems.org. 2014-03-21 08:10:47 +11:00
Sebastian Huber
51f823c932 posix: Use interal mutex for once implementation
Enable pthread_once() for all configurations.  The pthread_once()
function is one means to initialize POSIX keys.  Another use case is the
C++ support.
2014-03-19 08:34:26 +01:00
Sebastian Huber
53ad908a64 score: Add SMP lock profiling support 2014-03-14 08:46:49 +01:00
Sebastian Huber
b4b86b825a posix: Fix NULL pointer access in pthread_create() 2014-03-11 14:21:42 +01:00
Sebastian Huber
d50acdbb6c score: Add local context to SMP lock API
Add a local context structure to the SMP lock API for acquire and
release pairs.  This context can be used to store the ISR level and
profiling information.  It may be later used to enable more
sophisticated lock algorithms, e.g. MCS locks.

There is only one lock that cannot be used with a local context.  This
is the per-CPU lock since here we would have to transfer the local
context through a context switch which is very complicated.
2014-03-11 10:58:09 +01:00