📄 tx_qs.c
字号:
into its storage area. */
thread_ptr = queue_ptr -> tx_queue_suspension_list;
/* See if this is the only suspended thread on the list. */
if (thread_ptr == thread_ptr -> tx_suspended_next)
{
/* Yes, the only suspended thread. */
/* Update the head pointer. */
queue_ptr -> tx_queue_suspension_list = TX_NULL;
}
else
{
/* At least one more thread is on the same expiration list. */
/* Update the list head pointer. */
queue_ptr -> tx_queue_suspension_list = thread_ptr -> tx_suspended_next;
/* Update the links of the adjacent threads. */
(thread_ptr -> tx_suspended_next) -> tx_suspended_previous =
thread_ptr -> tx_suspended_previous;
(thread_ptr -> tx_suspended_previous) -> tx_suspended_next =
thread_ptr -> tx_suspended_next;
}
/* Decrement the suspension count. */
queue_ptr -> tx_queue_suspended_count--;
/* Prepare for resumption of the thread. */
/* Clear cleanup routine to avoid timeout. */
thread_ptr -> tx_suspend_cleanup = TX_NULL;
/* Temporarily disable preemption. */
_tx_thread_preempt_disable++;
/* Restore interrupts. */
TX_RESTORE
/* Setup source and destination pointers. */
source = (ULONG *) source_ptr;
destination = (ULONG *) thread_ptr -> tx_additional_suspend_info;
/* Copy the message into the thread's destination. */
if (queue_ptr -> tx_queue_message_size == TX_1_ULONG)
{
/* Copy single longword message into the thread's destination. */
*destination = *source;
}
else if (queue_ptr -> tx_queue_message_size == TX_2_ULONG)
{
/* Copy double longword message into the thread's destination. */
*destination++ = *source++;
*destination = *source;
}
else if (queue_ptr -> tx_queue_message_size == TX_4_ULONG)
{
/* Copy a four longword message into the thread's destination. */
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination = *source;
}
else if (queue_ptr -> tx_queue_message_size == TX_8_ULONG)
{
/* Copy an eight longword message into the thread's destination. */
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination = *source;
}
else
{
/* Copy a sixteen longword message into the thread's destination. */
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination++ = *source++;
*destination = *source;
}
/* Deactivate the timeout timer if necessary. */
if (thread_ptr -> tx_thread_timer.tx_list_head)
{
/* Deactivate the thread's timeout timer. */
_tx_timer_deactivate(&(thread_ptr -> tx_thread_timer));
}
else
{
/* Clear the remaining time to ensure timer doesn't get activated. */
thread_ptr -> tx_thread_timer.tx_remaining_ticks = 0;
}
/* Put return status into the thread control block. */
thread_ptr -> tx_suspend_status = TX_SUCCESS;
/* Resume thread. */
if (_tx_thread_resume(thread_ptr))
/* Preemption is required, transfer control back to
system. */
_tx_thread_system_return();
/* Return successful status. */
return(TX_SUCCESS);
}
}
else
{
/* Determine if the request specifies suspension. */
if (wait_option)
{
/* Prepare for suspension of this thread. */
/* Pickup thread pointer. */
thread_ptr = _tx_thread_current_ptr;
/* Setup cleanup routine pointer. */
thread_ptr -> tx_suspend_cleanup = _tx_queue_cleanup;
/* Setup cleanup information, i.e. this queue control
block and the source pointer. */
thread_ptr -> tx_suspend_control_block = (VOID_PTR) queue_ptr;
thread_ptr -> tx_additional_suspend_info = (VOID_PTR) source_ptr;
/* Setup suspension list. */
if (queue_ptr -> tx_queue_suspension_list)
{
/* This list is not NULL, add current thread to the end. */
thread_ptr -> tx_suspended_next =
queue_ptr -> tx_queue_suspension_list;
thread_ptr -> tx_suspended_previous =
(queue_ptr -> tx_queue_suspension_list) -> tx_suspended_previous;
((queue_ptr -> tx_queue_suspension_list) -> tx_suspended_previous) -> tx_suspended_next =
thread_ptr;
(queue_ptr -> tx_queue_suspension_list) -> tx_suspended_previous = thread_ptr;
}
else
{
/* No other threads are suspended. Setup the head pointer and
just setup this threads pointers to itself. */
queue_ptr -> tx_queue_suspension_list = thread_ptr;
thread_ptr -> tx_suspended_next = thread_ptr;
thread_ptr -> tx_suspended_previous = thread_ptr;
}
/* Increment the suspended thread count. */
queue_ptr -> tx_queue_suspended_count++;
/* Set the state to suspended. */
thread_ptr -> tx_state = TX_QUEUE_SUSP;
/* Set the suspending flag. */
thread_ptr -> tx_suspending = TX_TRUE;
/* Temporarily disable preemption. */
_tx_thread_preempt_disable++;
/* Save the timeout value. */
thread_ptr -> tx_thread_timer.tx_remaining_ticks = wait_option;
/* Restore interrupts. */
TX_RESTORE
/* See if we need to start a timer. */
if (wait_option != TX_WAIT_FOREVER)
{
/* A timeout is required. */
/* Activate the thread timer for timeout. */
_tx_timer_activate(&(thread_ptr -> tx_thread_timer));
}
/* Call actual thread suspension routine. */
_tx_thread_suspend(thread_ptr);
/* Return the completion status. */
return(thread_ptr -> tx_suspend_status);
}
else
/* Immediate return, return error completion. */
status = TX_QUEUE_FULL;
}
/* Restore interrupts. */
TX_RESTORE
/* Return completion status. */
return(status);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -