Commit Graph

962 Commits

Author SHA1 Message Date
Sebastian Huber
df55d07f2e score: Untangle thread actions
Remove the thread action handler parameter from
_Thread_Action_initialize() and instead set it later in
_Thread_Add_post_switch_action().  This avoids a dependency on the
thread action handler via the thread initialization.
2015-12-11 08:20:48 +01:00
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
Sebastian Huber
f97536dcd3 basdefs.h: Add and use RTEMS_UNUSED 2015-10-26 09:13:19 +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
3b3d1489e4 posix: glibc compatibility 2015-09-02 14:05:02 +02:00
Sebastian Huber
1f242285df posix: Avoid _RBTree_Next() 2015-08-31 09:56:55 +02: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
e273501233 score: Introduce Thread_queue_Queue
Separate the thread queue heads and lock from the operations.  This
enables the support for light weight objects which only support one
queuing discipline.
2015-07-23 08:00:19 +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
48fed9a56e score: Simplify <rtems/system.h>
Drop the <rtems/score/percpu.h> include since this file exposes a lot of
implementation details.
2015-06-26 09:16:25 +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
80fca28198 score: Add _Watchdog_Preinitialize()
Add an assert to ensure that the watchdog is the proper state for a
_Watchdog_Initialize().  This helps to detect invalid initializations
which may lead to a corrupt watchdog chain.
2015-06-13 15:51:21 +02:00
Sebastian Huber
258d580c42 score: Delete unused state WATCHDOG_REMOVE_IT 2015-06-13 14:49:23 +02:00
Sebastian Huber
335e5caa9a score: Add Thread_Control::is_fp
Store the floating-point unit property in the thread control block
regardless of the CPU_HARDWARE_FP and CPU_SOFTWARE_FP settings.  Make
sure the floating-point unit is only enabled for the corresponding
multilibs.  This helps targets which have a volatile only floating point
context like SPARC for example.
2015-06-09 09:05:50 +02:00
Sebastian Huber
f9a2d36455 posix: Fix _POSIX_Timer_Insert_helper() locking
Close #2358.
2015-06-03 09:18:52 +02:00
Sebastian Huber
8f6a31459c posix: Fix clock_gettime()
The _TOD_Get_zero_based_uptime_as_timespec() returns already the right
value.
2015-05-29 15:03:46 +02:00
Alexander Krutwig
7cd2484c4c timecounter: Use in RTEMS
Replace timestamp implementation with FreeBSD bintime and timecounters.

New test sptests/sptimecounter02.

Update #2271.
2015-05-20 08:40:33 +02:00
Sebastian Huber
aa05cfbb3d score: Replace _Thread_Delay_ended()
Use _Thread_Timeout() instead.  Use pseudo thread queue for nanosleep()
to deal with signals.

Close #2130.
2015-05-19 12:00:48 +02:00
Sebastian Huber
900d337f96 score: Rework _Thread_Change_priority()
Move the writes to Thread_Control::current_priority and
Thread_Control::real_priority into _Thread_Change_priority() under the
protection of the thread lock.  Add a filter function to
_Thread_Change_priority() to enable specialized variants.

Avoid race conditions during a thread priority restore with the new
Thread_Control::priority_restore_hint for an important average case
optimizations used by priority inheritance mutexes.

Update #2273.
2015-05-19 12:00:47 +02:00
Sebastian Huber
4438ac2575 score: Fine grained locking for mutexes
Update #2273.
2015-05-19 12:00:47 +02:00
Sebastian Huber
cfa5aabc78 score: Delete _CORE_semaphore_Seize()
Rename _CORE_semaphore_Seize_isr_disable() to _CORE_semaphore_Seize().
2015-05-19 12:00:46 +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
f5d6c8b58d score: Delete Thread_queue_Control::timeout_status
Use a parameter for _Thread_queue_Enqueue() instead to reduce memory
usage.
2015-05-19 12:00:46 +02:00
Sebastian Huber
383cf42217 score: More thread queue operations
Move thread queue discipline specific operations into
Thread_queue_Operations.  Use a separate node in the thread control
block for the thread queue to make it independent of the scheduler data
structures.

Update #2273.
2015-05-19 12:00:45 +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
290309014c score: Add header to _Watchdog_Remove()
Add watchdog header parameter to _Watchdog_Remove() to be in line with
the other operations.  Add _Watchdog_Remove_ticks() and
_Watchdog_Remove_seconds() for convenience.

Update #2307.
2015-05-19 12:00:42 +02:00
Sebastian Huber
56729d83c9 score: Delete STATES_WAITING_ON_THREAD_QUEUE
Avoid the usage of the current thread state in
_Thread_queue_Extract_with_return_code() since thread queues should not
know anything about thread states.
2015-05-19 12:00:42 +02:00
Sebastian Huber
d83127e9bd posix: Use right thread dispatch disable function 2015-04-24 08:36:52 +02:00
Sebastian Huber
f32935335a score: Fix POSIX thread join
A thread join is twofold.  There is one thread that exists and an
arbitrary number of threads that wait for the thread exit (one-to-many
relation).  The exiting thread may want to wait for a thread that wants
to join its exit (STATES_WAITING_FOR_JOIN_AT_EXIT in
_POSIX_Thread_Exit()).  On the other side we need a thread queue for all
the threads that wait for the exit of one particular thread
(STATES_WAITING_FOR_JOIN in pthread_join()).

Update #2035.
2015-04-23 21:42:13 +02:00
Sebastian Huber
9f10911d2b score: Delete Thread_queue_Control::state
Use a parameter for _Thread_queue_Enqueue() instead to reduce memory
usage.
2015-04-23 08:55:43 +02:00
Sebastian Huber
49d436497e score: Delete bogus THREAD_QUEUE_WAIT_FOREVER
It makes no sense to use this indirection since the type for timeout
values is Watchdog_Interval.
2015-04-22 11:38:57 +02:00
Sebastian Huber
3bf4a9fac4 score: _Objects_Get_isr_disable()
Do not disable thread dispatching and do not acquire the Giant lock.
This makes it possible to use this object get variant for fine grained
locking.

Update #2273.
2015-04-21 08:25:31 +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
Joel Sherrill
1047f37cac semdestroy.c: Add missing _Objects_Allocator_unlock()
closes 2319.
2015-04-14 12:12:50 -05:00
Daniel Krueger
5049dca6c5 semunlink.c: Add missing _Objects_Allocator_unlock()
updates 2319.

Signed-off-by: Daniel Krueger <daniel.krueger@systec-electronic.com>
2015-04-14 12:12:40 -05:00
Sebastian Huber
1dc6662276 score: Rename _Watchdog_Reset()
Update #2307.
2015-04-14 08:21:51 +02:00
Joel Sherrill
d937d364af posix/src/nanosleep.c: Address issue when delay is longer than desired
This resulted in the elapsed time going below 0 and an arbitrarily large
number returned as the time remaining.

closes #2296.
2015-03-12 13:33:36 -05:00
Daniel Cederman
b0f8bb4eec posix: Return error code if mmap is used 2015-03-12 10:02:33 -04:00
Daniel Cederman
d88b0b78d7 posix: Move function to file with matching name
mmap was previously in munmap.c and munmap was in mmap.c.
2015-03-12 10:02:33 -04:00
Sebastian Huber
f244bfc5f8 posix: Install <semaphore.h> only if not provided 2015-03-10 08:56:06 +01: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
f0ff18e035 score: Add rtems_set_errno_and_return_value()
Remove rtems_set_errno_and_return_minus_one_cast().
2015-03-10 08:55:10 +01:00
Sebastian Huber
40ecd117b2 sysconf: Add _SC_NPROCESSORS_(CONF|ONLN) 2015-03-09 15:25:24 +01:00
Sebastian Huber
8552df6514 sysconf: Simplify 2015-03-09 15:25:17 +01:00
Sebastian Huber
6157743d67 score: Simplify and fix signal delivery
Deliver the POSIX signals after the thread state was updated to avoid
race-conditions on SMP configurations.

Update #2273.
2015-03-05 11:36:19 +01:00
Gedare Bloom
c0e01a28da posix: fix error return code for pthread_mutex_trylock
pthread_mutex_trylock() should return EBUSY if the mutex is already
locked. The translations of CORE_MUTEX_STATUS_NESTING_NOT_ALLOWED is
EDEADLK which is correct for pthread_mutex_lock(). This fixes the
translation for trylock.

Closes #2170.
2015-02-25 15:00:41 -05:00
Sebastian Huber
8ce00eaf48 posix: Delete unused _POSIX_Threads_Get()
Close #1759.
2014-12-18 10:48:35 +01:00