📄 nu.c
字号:
/* Check to see if we should schedule a timeout for this
action. */
if (wait_timeout != NU_WAIT_FOREVER)
{
/* A timeout is requested, call "CLP_Start_Timer" to
start the timeout. */
CLP_Start_Timer(task_id, wait_timeout);
}
/* Wait for something to appear in the queue. */
status = QM_Wait_To_Retrieve(task_id,queue_id,destination_ptr);
/* Check to see if we need to delete a previously scheduled
timer. */
if ((wait_timeout != NU_WAIT_FOREVER) &&
(status != NU_QUEUE_TIMEOUT))
{
/* Delete the previously scheduled timeout. */
CLP_Stop_Timer(task_id);
}
}
}
}
else
/* Invalid queue id, status as such. */
status = NU_INVALID_QUEUE;
/* Restore previous interrupt level. */
IND_Set_Interrupt_Level(interrupt_level);
/* Return the status to caller. */
return(status);
} /* end of NU_Retrieve_Item */
/************************************************************************/
/* */
/* FUNCTION "NU_Send_Item" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to send an item to a queue. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* Application Routines */
/* */
/* ROUTINES CALLED */
/* */
/* DS_Make_History_Entry Make an history entry */
/* QM_Place_Item Place an item in a queue */
/* CLP_Start_Timer Start a timer for queue full*/
/* QM_Wait_To_Place Wait for room to place item */
/* CLP_Stop_Timer Stop timer */
/* IND_Set_Interrupt_Level Disable/Enable Interrupts */
/* */
/* INPUTS */
/* */
/* queue_id Queue to send to */
/* source_ptr Pointer to source area */
/* wait_timeout How long to wait */
/* */
/* OUTPUTS */
/* */
/* Queue */
/* return(status) Status of request */
/* */
/************************************************************************/
signed int NU_Send_Item(signed int queue_id, unsigned int *source_ptr,
signed int wait_timeout)
{
signed int task_id; /* Current task's ID */
int interrupt_level; /* Saved interrupt level */
signed int status; /* Return status */
/* Make an entry in the history table, if the conditional compilation
flag is set. */
#ifdef NU_ENABLE_HISTORY
DS_Make_History_Entry(NU_HIST_NU_SEND_ITEM,
(unsigned int) queue_id,
(unsigned int) source_ptr);
#endif
/* Lock out interrupts while checking. */
interrupt_level = IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
/* Check for a valid queue entry. */
if ((queue_id >= 0) && (queue_id < NU_Total_Queues))
{
/* Call "QM_Place_Item" to place an item on a queue. */
status = QM_Place_Item(queue_id, source_ptr);
/* Check to see if we need to wait before placing the item. */
if ((status == NU_QUEUE_FULL) && (wait_timeout != NU_NO_TIMEOUT))
{
/* Get the task_id. */
task_id = SKP_Get_Task_ID();
/* Check for a valid task ID. */
if (task_id != NU_SYSTEM)
{
/* Check for a timeout request. */
if (wait_timeout != NU_WAIT_FOREVER)
{
/* A timeout is requested, call "CLP_Start_Timer" to
start the timer for this operation. */
CLP_Start_Timer(task_id, wait_timeout);
}
/* Wait for something to appear in the queue. */
status = QM_Wait_To_Place(task_id, queue_id, source_ptr);
/* Check to see if we need to delete a previously scheduled
timer. */
if ((wait_timeout != NU_WAIT_FOREVER) &&
(status != NU_QUEUE_TIMEOUT))
{
/* Delete the previously scheduled timeout. */
CLP_Stop_Timer(task_id);
}
}
}
}
else
/* Invalid queue id, status as such. */
status = NU_INVALID_QUEUE;
/* Restore previous interrupt level. */
IND_Set_Interrupt_Level(interrupt_level);
/* Return the status to caller. */
return(status);
} /* end of NU_Send_Item */
/************************************************************************/
/* */
/* FUNCTION "NU_Retrieve_Item_Mult" */
/* */
/* */
/* DESCRIPTION */
/* */
/* This function is used to retrieve an item from a set of queues. */
/* */
/* AUTHOR */
/* */
/* William E. Lamie, Accelerated Technology */
/* */
/* CALLED FROM */
/* */
/* Application Routines */
/* */
/* ROUTINES CALLED */
/* */
/* DS_Make_History_Entry Make an history entry */
/* QM_Retrieve_Item Get an item from a queue */
/* QM_Wait_To_Retrieve_Mult Wait for an item */
/* CLP_Start_Timer Start a timeout timer */
/* CLP_Stop_Timer Stop a timeout timer */
/* IND_Set_Interrupt_Level Disable/Enable Interrupts */
/* */
/* INPUTS */
/* */
/* queue_id_x Queue(s) to retrieve from */
/* destination_ptr Pointer to destination are */
/* wait_timeout How long to wait */
/* */
/* OUTPUTS */
/* */
/* Queue and destination area */
/* return(status) Status of request */
/* */
/************************************************************************/
signed int NU_Retrieve_Item_Mult(signed int queue_id_1, signed int queue_id_2,
signed int queue_id_3, unsigned int *destination_ptr,
signed int wait_timeout)
{
signed int task_id; /* Current task's ID */
int interrupt_level; /* Saved interrupt level */
signed int status; /* Return status */
/* Make an entry in the history table, if the conditional compilation
flag is set. */
#ifdef NU_ENABLE_HISTORY
DS_Make_History_Entry(NU_HIST_NU_RETRIEVE_ITEM_MULT,
(unsigned int) queue_id_1,
(unsigned int) queue_id_2);
#endif
/* Lock out interrupts while checking. */
interrupt_level = IND_Set_Interrupt_Level(NU_DISABLE_INTERRUPTS);
/* Default to an invalid queue id to make error checking easier on the
three queues. */
status = NU_INVALID_QUEUE;
/* Check for a valid queue entry. */
if ( ((queue_id_1 == NU_IGNORE_VALUE) ||
((queue_id_1 >= 0) && (queue_id_1 < NU_Total_Queues))) &&
((queue_id_2 == NU_IGNORE_VALUE) ||
((queue_id_2 >= 0) && (queue_id_2 < NU_Total_Queues))) &&
((queue_id_3 == NU_IGNORE_VALUE) ||
((queue_id_3 >= 0) && (queue_id_3 < NU_Total_Queues)))
)
{
/* Check each specified queue. Note that a suspend can be on 1, 2, or
3 queues at a time... Stop when something is found. */
if (queue_id_1 != NU_IGNORE_VALUE)
{
/* Call "QM_Retrieve_Item" to get an item from a queue. */
status = QM_Retrieve_Item(queue_id_1, destination_ptr);
}
if (((status == NU_INVALID_QUEUE) || (status == NU_QUEUE_EMPTY)) &&
(queue_id_2 != NU_IGNORE_VALUE))
{
/* Call "QM_Retrieve_Item" to get an item from a queue. */
status = QM_Retrieve_Item(queue_id_2, destination_ptr);
}
if (((status == NU_INVALID_QUEUE) || (status == NU_QUEUE_EMPTY)) &&
(queue_id_3 != NU_IGNORE_VALUE))
{
/* Call "QM_Retrieve_Item" to get an item from a queue. */
status = QM_Retrieve_Item(queue_id_3, destination_ptr);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -