tailieunhanh - Real-Time Embedded Multithreading Using ThreadX and MIPS- P13

Real-Time Embedded Multithreading Using ThreadX and MIPS- P13:Although the history of embedded systems is relatively short, 1 the advances and successes of this fi eld have been profound. Embedded systems are found in a vast array of applications such as consumer electronics, “ smart ” devices, communication equipment, automobiles, desktop computers, and medical equipment. | 244 Chapter 13 TX_QUEUE my_queue CHAR name ULONG enqueued TX_THREAD first_suspended ULONG suspended_count ULONG available_storage TX_QUEUE next_queue UINT status Retrieve information about the previously created message queue my_queue. status tx_queue_info_get my_queue name enqueued available_storage first_suspended suspended_count next_queue If status equals TX_SUCCESS the information requested is valid. Figure Retrieving information about a message queue Status of Queue Effect of Prioritization Queue is empty The highest priority thread suspended for this queue will receive the next message placed on the queue Queue is full The highest priority thread suspended for this queue will send the next message to this queue when space becomes available Figure Effect of prioritizing a message queue suspension list If return variable status contains the value TX_SUCCESS we have retrieved valid information about the message queue. Prioritizing a Message Queue Suspension List The tx_queue_prioritize service places the highest priority thread suspended for a message queue at the front of the suspension list. This applies either to a thread waiting to receive a message from an empty queue or to a thread waiting to send a message to a full queue as described in Figure . All other threads remain in the same FIFO order in which they were suspended. on to remove this watermark. Thread Communication with Message Queues 245 TX_QUEUE my_queue UINT status Depending on the queue status this service ensures that the highest priority thread will either receive the next message placed on this queue or will send the next message to the queue. status tx_queue_prioritize my_queue If status equals TX_SUCCESS the highest priority suspended thread is at the front of the list. If the suspended thread is waiting to receive a message the next tx_queue_send or tx_queue_front_send call made to this queue will wake up this thread. If the suspended thread is .