Commit Graph

277 Commits

Author SHA1 Message Date
Sebastian Huber
f6a1ef9fdb posix: Require struct _pthread_cleanup_context
This structure is available in Newlib since 2013-11-29 (Git commit
a534dfd26e765047621acd0eda656ded886e7108).
2015-11-24 16:00:14 +01:00
Martin Galvan
7def219b84 various .h files: Add missing C++ extern wrappers
Updates #2405.
2015-09-03 11:28:04 -05:00
Sebastian Huber
21789a2117 score: Rename _POSIX_Absolute_timeout_to_ticks()
Rename _POSIX_Absolute_timeout_to_ticks() to
_TOD_Absolute_timeout_to_ticks() and move it to the score directory.
Delete empty <rtems/posix/time.h>.
2015-07-28 14:54:51 +02:00
Sebastian Huber
d7665823b2 score: Introduce Thread_queue_Heads
Move the storage for the thread queue heads to the threads.  Each thread
provides a set of thread queue heads allocated from a dedicated memory
pool.  In case a thread blocks on a queue, then it lends its heads to
the queue.  In case the thread unblocks, then it takes a free set of
threads from the queue.  Since a thread can block on at most one queue
this works.  This mechanism is used in FreeBSD.  The motivation for this
change is to reduce the memory demands of the synchronization objects.
On a 32-bit uni-processor configuration the Thread_queue_Control size is
now 8 bytes, compared to 64 bytes in RTEMS 4.10 (other changes reduced
the size as well).
2015-07-23 08:01:13 +02:00
Sebastian Huber
fdb45d6b26 score: Freechain handler API changes
Replace the extend function with an allocator since this fits better
to the current use case.
2015-07-01 08:24:31 +02:00
Sebastian Huber
bd67d7d2f8 score: Simplify <rtems/score/thread.h>
Avoid Thread_Control typedef in <rtems/score/percpu.h>.  This helps to
get rid of the <rtems/score/percpu.h> include in <rtems/score/thread.h>
which exposes a lot of implementation details.
2015-06-25 13:55:34 +02:00
Sebastian Huber
e76c517d07 score: Fine grained locking for semaphores
Update #2273.
2015-05-19 12:00:46 +02:00
Sebastian Huber
cc18d7bec7 score: Fine grained locking for message queues
Aggregate several critical sections into a bigger one.  Sending and
receiving messages is now protected by an ISR lock.  Thread dispatching
is only disabled in case a blocking operation is necessary.  The message
copy procedure is done inside the critical section (interrupts
disabled).  Thus this change may have a negative impact on the interrupt
latency in case very large messages are transferred.

Update #2273.
2015-05-19 12:00:46 +02:00
Sebastian Huber
02c4c441a5 score: Add Thread_queue_Control::Lock
Move the complete thread queue enqueue procedure into
_Thread_queue_Enqueue_critical().  It is possible to use the thread
queue lock to protect state of the object embedding the thread queue.
This enables per object fine grained locking in the future.

Delete _Thread_queue_Enter_critical_section().

Update #2273.
2015-05-19 12:00:45 +02:00
Sebastian Huber
4db0ae8e07 score: _Objects_Get_isr_disable()
Use ISR_lock_Context instead of ISR_Level to allow use of ISR locks for
low-level locking.

Update #2273.
2015-04-21 08:25:31 +02:00
Sebastian Huber
77e682ec85 posix: Change sem_t to the 32-bit object type
This change is also valid for 16-bit object type architectures since in
this case POSIX_Semaphore_Control::Semaphore_id is used as a proxy.
2015-03-10 08:56:06 +01:00
Sebastian Huber
60bded9f8b posix: Use a value of 0 for SEM_FAILED
This is the standard NULL pointer.
2015-03-10 08:56:05 +01:00
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
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
b9f952254b posix: Add auto initializaton for rwlock 2014-10-08 11:26:27 +02:00
Sebastian Huber
05ac47d75e posix: Use RTEMS_DECONST() 2014-09-08 07:53:02 +02: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
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
Joel Sherrill
69d7279bd5 pthreadimpl.h: Conditionalize thread affinity copying 2014-04-03 17:02:40 -05: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
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
fc521e2df6 posix: Use thread action for signals 2014-03-31 08:29:43 +02: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
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
Joel Sherrill
e6c87f7872 POSIX keys now enabled in all configurations.
Formerly POSIX keys were only enabled when POSIX threads
were enabled. Because they are a truly safe alternative
to per-task variables in an SMP system, they are being
enabled in all configurations.
2014-03-07 13:21:11 -06:00
Jennifer Averett
5c3323492e Remove trailing whitespace in previous patches 2014-03-07 09:15:15 -06:00
Jennifer Averett
185e46f6a0 posix: Add POSIX thread affinity attribute support.
With the addition of pthread affinity information in pthread_attr_t,
the existing code for pthread_attr_t had to be adjusted.
2014-03-07 09:10:33 -06:00
Joel Sherrill
96281908a2 psignalimpl.h: Remove dead comment 2013-12-09 19:50:55 -06:00
Joel Sherrill
01d43180dd posix/config.h: Comment clean up 2013-12-09 19:50:55 -06:00
Joel Sherrill
2b3a648fe1 signalcatch.c: Remove junk comment 2013-12-09 19:50:55 -06:00
Joel Sherrill
16b1c350f0 timerimpl.h: Comment clean up 2013-12-09 19:50:55 -06:00
Joel Sherrill
610825b1e2 semaphoreimpl.h: Comment clean up 2013-12-09 19:50:55 -06:00
Joel Sherrill
849b98e83f mqueueimpl.h: Comment clean up 2013-12-09 19:50:55 -06:00
Joel Sherrill
07a3aa9d70 condimpl.h: Comment clean up 2013-12-09 19:50:55 -06:00
Joel Sherrill
71f2a83d5d ptimer.h: Comment clean up 2013-12-09 19:50:55 -06:00
Joel Sherrill
4600bd7cfe muteximpl.h: Comment clean up 2013-12-09 19:50:55 -06:00
Sebastian Huber
927a0a1f99 posix: Use cleanup contexts on the stack
Provide support for latest Newlib <pthread.h> change.  The cleanup
contexts are stored on the thread stack.  This is conformant with the
POSIX requirements for the pthread_cleanup_push() and
pthread_cleanup_pop() statement pair.

Passing an invalid pointer as the routine to pthread_cleanup_push() is
now a usage error and the behaviour is undefined.
2013-12-02 09:24:51 +01:00
Sebastian Huber
7d9fff6e28 posix: Add and use _POSIX_signals_Acquire()
Add and use _POSIX_signals_Release().  The post-switch handler is not
protected by disabled thread dispatching.  Use proper SMP lock for
signal management.
2013-08-27 12:51:46 +02:00
Chris Johns
6e4c01e3a2 posix: Update to the pthread_once changes.
Implement the reeview changes.
Add a POSIX Fatal error domain.
Fix confdefs.h to correctly handle the internal POSIX mutexes.
2013-08-23 14:56:36 +10:00
Sebastian Huber
ec98c997e8 posix: Typo 2013-08-14 11:55:51 +02:00
Chris Johns
03acc5915e posix: Change pthread_once to be SMP safe.
Change pthread_once from using disabled pre-emption to using a
pthread mutex making it SMP safe. GCC using a posix threading
model uses pthread_once.

The pthread mutex requires at least 1 mutex is configured so
confdefs.h has been updated to account for the internal
mutex.
2013-08-14 10:21:41 +10:00
Sebastian Huber
c9b784f3e7 posix: Delete POSIX_Keys_Freechain type
Use the POSIX configuration value directly.  Use right type early and
avoid casts.  Use proper unlimited objects API.  Check workspace
allocation.  Make functions static.
2013-08-08 14:11:21 +02:00
Chris Johns
f65e8e66d0 posix: Add missing header. 2013-08-08 10:21:54 +10:00
Sebastian Huber
2ad250e92d posix: Create key implementation header
Move implementation specific parts of key.h and key.inl into new header
file keyimpl.h.  The key.h contains now only the application visible
API.
2013-08-06 15:47:57 +02:00