mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 00:25:13 +08:00
score: Delete Thread_queue_Control::state
Use a parameter for _Thread_queue_Enqueue() instead to reduce memory usage.
This commit is contained in:
@@ -61,27 +61,6 @@ static rtems_id pipe_semaphore = RTEMS_ID_NONE;
|
||||
#define PIPE_WAKEUPWRITERS(_pipe) \
|
||||
do {uint32_t n; rtems_barrier_release(_pipe->writeBarrier, &n); } while(0)
|
||||
|
||||
|
||||
#ifdef RTEMS_POSIX_API
|
||||
#include <rtems/rtems/barrier.h>
|
||||
#include <rtems/score/thread.h>
|
||||
|
||||
/* Set barriers to be interruptible by signals. */
|
||||
static void pipe_interruptible(pipe_control_t *pipe)
|
||||
{
|
||||
Objects_Locations location;
|
||||
Barrier_Control *the_barrier;
|
||||
|
||||
the_barrier = _Barrier_Get(pipe->readBarrier, &location);
|
||||
the_barrier->Barrier.Wait_queue.state |= STATES_INTERRUPTIBLE_BY_SIGNAL;
|
||||
_Objects_Put( &the_barrier->Object );
|
||||
|
||||
the_barrier = _Barrier_Get(pipe->writeBarrier, &location);
|
||||
the_barrier->Barrier.Wait_queue.state |= STATES_INTERRUPTIBLE_BY_SIGNAL;
|
||||
_Objects_Put( &the_barrier->Object );
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Alloc pipe control structure, buffer, and resources.
|
||||
* Called with pipe_semaphore held.
|
||||
@@ -122,10 +101,6 @@ static int pipe_alloc(
|
||||
RTEMS_NO_PRIORITY, &pipe->Semaphore) != RTEMS_SUCCESSFUL)
|
||||
goto err_sem;
|
||||
|
||||
#ifdef RTEMS_POSIX_API
|
||||
pipe_interruptible(pipe);
|
||||
#endif
|
||||
|
||||
*pipep = pipe;
|
||||
if (c ++ == 'z')
|
||||
c = 'a';
|
||||
|
||||
@@ -65,7 +65,6 @@ int pthread_cond_init(
|
||||
_Thread_queue_Initialize(
|
||||
&the_cond->Wait_queue,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_CONDITION_VARIABLE | STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
ETIMEDOUT
|
||||
);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/posix/condimpl.h>
|
||||
#include <rtems/posix/time.h>
|
||||
#include <rtems/posix/muteximpl.h>
|
||||
@@ -79,7 +80,13 @@ int _POSIX_Condition_variables_Wait_support(
|
||||
executing->Wait.queue = &the_cond->Wait_queue;
|
||||
executing->Wait.id = *cond;
|
||||
|
||||
_Thread_queue_Enqueue( &the_cond->Wait_queue, executing, timeout );
|
||||
_Thread_queue_Enqueue(
|
||||
&the_cond->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_CONDITION_VARIABLE
|
||||
| STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
timeout
|
||||
);
|
||||
|
||||
_Objects_Put( &the_cond->Object );
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <rtems/score/isrlevel.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/watchdogimpl.h>
|
||||
@@ -194,7 +193,6 @@ void _POSIX_signals_Manager_Initialization(void)
|
||||
_Thread_queue_Initialize(
|
||||
&_POSIX_signals_Wait_queue,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
EAGAIN
|
||||
);
|
||||
|
||||
|
||||
@@ -238,7 +238,6 @@ static bool _POSIX_Threads_Create_extension(
|
||||
_Thread_queue_Initialize(
|
||||
&api->Join_List,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <rtems/posix/pthreadimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
|
||||
int pthread_join(
|
||||
pthread_t thread,
|
||||
@@ -70,6 +71,7 @@ on_EINTR:
|
||||
_Thread_queue_Enqueue(
|
||||
&api->Join_List,
|
||||
executing,
|
||||
STATES_WAITING_FOR_JOIN_AT_EXIT | STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
WATCHDOG_NO_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -158,7 +158,12 @@ int sigtimedwait(
|
||||
executing->Wait.return_argument = the_info;
|
||||
_Thread_queue_Enter_critical_section( &_POSIX_signals_Wait_queue );
|
||||
_POSIX_signals_Release( &lock_context );
|
||||
_Thread_queue_Enqueue( &_POSIX_signals_Wait_queue, executing, interval );
|
||||
_Thread_queue_Enqueue(
|
||||
&_POSIX_signals_Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_SIGNAL | STATES_INTERRUPTIBLE_BY_SIGNAL,
|
||||
interval
|
||||
);
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <rtems/rtems/attrimpl.h>
|
||||
#include <rtems/rtems/support.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
|
||||
/*
|
||||
@@ -94,7 +93,6 @@ rtems_status_code rtems_region_create(
|
||||
&the_region->Wait_queue,
|
||||
_Attributes_Is_priority( attribute_set ) ?
|
||||
THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_SEGMENT,
|
||||
RTEMS_TIMEOUT
|
||||
);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <rtems/rtems/optionsimpl.h>
|
||||
#include <rtems/score/apimutex.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
|
||||
rtems_status_code rtems_region_get_segment(
|
||||
rtems_id id,
|
||||
@@ -88,6 +89,7 @@ rtems_status_code rtems_region_get_segment(
|
||||
_Thread_queue_Enqueue(
|
||||
&the_region->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_SEGMENT,
|
||||
timeout
|
||||
);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <rtems/score/coresem.h>
|
||||
#include <rtems/score/threaddispatch.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -238,7 +239,12 @@ RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
|
||||
executing->Wait.id = id;
|
||||
_ISR_lock_ISR_enable( lock_context );
|
||||
|
||||
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
|
||||
_Thread_queue_Enqueue(
|
||||
&the_semaphore->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_SEMAPHORE,
|
||||
timeout
|
||||
);
|
||||
_Thread_Enable_dispatch();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,6 @@ typedef struct {
|
||||
Thread_blocking_operation_States sync_state;
|
||||
/** This field indicates the thread queue's blocking discipline. */
|
||||
Thread_queue_Disciplines discipline;
|
||||
/** This indicates the blocking state for threads waiting on this
|
||||
* thread queue.
|
||||
*/
|
||||
States_Control state;
|
||||
/** This is the status value returned to threads which timeout while
|
||||
* waiting on this thread queue.
|
||||
*/
|
||||
|
||||
@@ -71,6 +71,7 @@ Thread_Control *_Thread_queue_Dequeue(
|
||||
*
|
||||
* @param[in] the_thread_queue pointer to threadq
|
||||
* @param[in] the_thread the thread to enqueue
|
||||
* @param[in] state is the new state of the thread
|
||||
* @param[in] timeout interval to wait
|
||||
*
|
||||
* - INTERRUPT LATENCY:
|
||||
@@ -79,6 +80,7 @@ Thread_Control *_Thread_queue_Dequeue(
|
||||
void _Thread_queue_Enqueue(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Thread_Control *the_thread,
|
||||
States_Control state,
|
||||
Watchdog_Interval timeout
|
||||
);
|
||||
|
||||
@@ -170,13 +172,11 @@ void _Thread_queue_Flush(
|
||||
*
|
||||
* @param[in] the_thread_queue is the pointer to a threadq header
|
||||
* @param[in] the_discipline is the queueing discipline
|
||||
* @param[in] state is the state of waiting threads
|
||||
* @param[in] timeout_status is the return on a timeout
|
||||
*/
|
||||
void _Thread_queue_Initialize(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Thread_queue_Disciplines the_discipline,
|
||||
States_Control state,
|
||||
uint32_t timeout_status
|
||||
);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/score/corebarrierimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
|
||||
void _CORE_barrier_Initialize(
|
||||
@@ -34,7 +33,6 @@ void _CORE_barrier_Initialize(
|
||||
_Thread_queue_Initialize(
|
||||
&the_barrier->Wait_queue,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_BARRIER,
|
||||
CORE_BARRIER_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <rtems/score/corebarrierimpl.h>
|
||||
#include <rtems/score/isrlevel.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
|
||||
void _CORE_barrier_Wait(
|
||||
@@ -51,5 +52,10 @@ void _CORE_barrier_Wait(
|
||||
executing->Wait.id = id;
|
||||
_ISR_Enable( level );
|
||||
|
||||
_Thread_queue_Enqueue( &the_barrier->Wait_queue, executing, timeout );
|
||||
_Thread_queue_Enqueue(
|
||||
&the_barrier->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_BARRIER,
|
||||
timeout
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
/*
|
||||
@@ -113,7 +112,6 @@ bool _CORE_message_queue_Initialize(
|
||||
&the_message_queue->Wait_queue,
|
||||
_CORE_message_queue_Is_priority( the_message_queue_attributes ) ?
|
||||
THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_MESSAGE,
|
||||
CORE_MESSAGE_QUEUE_STATUS_TIMEOUT
|
||||
);
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
void _CORE_message_queue_Seize(
|
||||
@@ -121,5 +122,10 @@ void _CORE_message_queue_Seize(
|
||||
/* Wait.count will be filled in with the message priority */
|
||||
_ISR_Enable( level );
|
||||
|
||||
_Thread_queue_Enqueue( &the_message_queue->Wait_queue, executing, timeout );
|
||||
_Thread_queue_Enqueue(
|
||||
&the_message_queue->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_MESSAGE,
|
||||
timeout
|
||||
);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <rtems/score/coremsgimpl.h>
|
||||
#include <rtems/score/objectimpl.h>
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
|
||||
CORE_message_queue_Status _CORE_message_queue_Submit(
|
||||
@@ -133,6 +134,7 @@ CORE_message_queue_Status _CORE_message_queue_Submit(
|
||||
_Thread_queue_Enqueue(
|
||||
&the_message_queue->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_MESSAGE,
|
||||
timeout
|
||||
);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,6 @@ CORE_mutex_Status _CORE_mutex_Initialize(
|
||||
&the_mutex->Wait_queue,
|
||||
_CORE_mutex_Is_fifo( the_mutex_attributes ) ?
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO : THREAD_QUEUE_DISCIPLINE_PRIORITY,
|
||||
STATES_WAITING_FOR_MUTEX,
|
||||
CORE_MUTEX_TIMEOUT
|
||||
);
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <rtems/score/isr.h>
|
||||
#include <rtems/score/coremuteximpl.h>
|
||||
#include <rtems/score/schedulerimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/thread.h>
|
||||
|
||||
#if defined(__RTEMS_DO_NOT_INLINE_CORE_MUTEX_SEIZE__)
|
||||
@@ -63,7 +64,12 @@ void _CORE_mutex_Seize_interrupt_blocking(
|
||||
);
|
||||
}
|
||||
|
||||
_Thread_queue_Enqueue( &the_mutex->Wait_queue, executing, timeout );
|
||||
_Thread_queue_Enqueue(
|
||||
&the_mutex->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_MUTEX,
|
||||
timeout
|
||||
);
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/score/corerwlockimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
|
||||
void _CORE_RWLock_Initialize(
|
||||
@@ -38,7 +37,6 @@ void _CORE_RWLock_Initialize(
|
||||
_Thread_queue_Initialize(
|
||||
&the_rwlock->Wait_queue,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_RWLOCK,
|
||||
CORE_RWLOCK_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <rtems/score/corerwlockimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
|
||||
void _CORE_RWLock_Obtain_for_reading(
|
||||
@@ -87,6 +88,7 @@ void _CORE_RWLock_Obtain_for_reading(
|
||||
_Thread_queue_Enqueue(
|
||||
&the_rwlock->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_RWLOCK,
|
||||
timeout
|
||||
);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include <rtems/score/corerwlockimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/watchdog.h>
|
||||
|
||||
void _CORE_RWLock_Obtain_for_writing(
|
||||
@@ -77,6 +78,7 @@ void _CORE_RWLock_Obtain_for_writing(
|
||||
_Thread_queue_Enqueue(
|
||||
&the_rwlock->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_RWLOCK,
|
||||
timeout
|
||||
);
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/score/coresemimpl.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
|
||||
void _CORE_semaphore_Initialize(
|
||||
CORE_semaphore_Control *the_semaphore,
|
||||
@@ -35,7 +34,6 @@ void _CORE_semaphore_Initialize(
|
||||
&the_semaphore->Wait_queue,
|
||||
_CORE_semaphore_Is_priority( the_semaphore_attributes ) ?
|
||||
THREAD_QUEUE_DISCIPLINE_PRIORITY : THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_SEMAPHORE,
|
||||
CORE_SEMAPHORE_TIMEOUT
|
||||
);
|
||||
}
|
||||
|
||||
@@ -63,6 +63,11 @@ void _CORE_semaphore_Seize(
|
||||
executing->Wait.queue = &the_semaphore->Wait_queue;
|
||||
executing->Wait.id = id;
|
||||
_ISR_Enable( level );
|
||||
_Thread_queue_Enqueue( &the_semaphore->Wait_queue, executing, timeout );
|
||||
_Thread_queue_Enqueue(
|
||||
&the_semaphore->Wait_queue,
|
||||
executing,
|
||||
STATES_WAITING_FOR_SEMAPHORE,
|
||||
timeout
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -83,7 +83,6 @@ void _MPCI_Handler_initialization(
|
||||
_Thread_queue_Initialize(
|
||||
&_MPCI_Remote_blocked_threads,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
STATES_WAITING_FOR_RPC_REPLY,
|
||||
timeout_status
|
||||
);
|
||||
}
|
||||
@@ -219,12 +218,10 @@ uint32_t _MPCI_Send_request_packet (
|
||||
_Thread_queue_Enqueue(
|
||||
&_MPCI_Remote_blocked_threads,
|
||||
executing,
|
||||
STATES_WAITING_FOR_RPC_REPLY | extra_state,
|
||||
the_packet->timeout
|
||||
);
|
||||
|
||||
executing->current_state =
|
||||
_States_Set( extra_state, executing->current_state );
|
||||
|
||||
_Thread_Enable_dispatch();
|
||||
|
||||
return executing->Wait.return_code;
|
||||
|
||||
@@ -47,11 +47,9 @@ RBTree_Compare_result _Thread_queue_Compare_priority(
|
||||
void _Thread_queue_Initialize(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Thread_queue_Disciplines the_discipline,
|
||||
States_Control state,
|
||||
uint32_t timeout_status
|
||||
)
|
||||
{
|
||||
the_thread_queue->state = state;
|
||||
the_thread_queue->discipline = the_discipline;
|
||||
the_thread_queue->timeout_status = timeout_status;
|
||||
the_thread_queue->sync_state = THREAD_BLOCKING_OPERATION_SYNCHRONIZED;
|
||||
|
||||
@@ -104,6 +104,7 @@ static void _Thread_queue_Requeue_priority(
|
||||
void _Thread_queue_Enqueue(
|
||||
Thread_queue_Control *the_thread_queue,
|
||||
Thread_Control *the_thread,
|
||||
States_Control state,
|
||||
Watchdog_Interval timeout
|
||||
)
|
||||
{
|
||||
@@ -112,13 +113,13 @@ void _Thread_queue_Enqueue(
|
||||
|
||||
#if defined(RTEMS_MULTIPROCESSING)
|
||||
if ( _Thread_MP_Is_receive( the_thread ) && the_thread->receive_packet )
|
||||
the_thread = _Thread_MP_Allocate_proxy( the_thread_queue->state );
|
||||
the_thread = _Thread_MP_Allocate_proxy( state );
|
||||
else
|
||||
#endif
|
||||
/*
|
||||
* Set the blocking state for this thread queue in the thread.
|
||||
*/
|
||||
_Thread_Set_state( the_thread, the_thread_queue->state );
|
||||
_Thread_Set_state( the_thread, state );
|
||||
|
||||
/*
|
||||
* If the thread wants to timeout, then schedule its timer.
|
||||
|
||||
@@ -33,7 +33,7 @@ void threadq_first_empty(
|
||||
Thread_queue_Control tq;
|
||||
|
||||
printf( "Init - initialize thread queue for %s\n", discipline_string );
|
||||
_Thread_queue_Initialize( &tq, discipline, 0x01, 3 );
|
||||
_Thread_queue_Initialize( &tq, discipline, 3 );
|
||||
|
||||
puts( "Init - _Thread_queue_Extract - thread not blocked on a thread queue" );
|
||||
_Thread_Disable_dispatch();
|
||||
|
||||
Reference in New Issue
Block a user