1.1. Communication, synchronization and mutual exclusive mechanism
VxWorks supports communication mechanism between various tasks, providing a variety of task communication methods, mainly aspects:
Ÿ Share memory, mainly data sharing;
Ÿ Signal volume, used for basic mutual exclusion and task synchronization;
Ÿ 消 Message queue and pipeline, single CPU messaging;
Ÿ Socket and remote procedure calls for network task messaging;
Ÿ Binary signal for abnormal processing.
The task between multiprocessors can also use shared memory objects to implement inter-task communication, just different in system configuration.
1.1.1. Share storage area
The easiest way to communicate between tasks is to use a shared storage area, that is, the associated task sharing the same memory area belonging to their address space. Because all tasks exist in a single linear address space, the task is shared between data. Global variables, linear queues, annular queues, linked lists, pointers can be directed at different codes of different contexts.
1.1.2. Mutually exclusive
When an address space is used for data exchange, it is very important to avoid conflicts. When two or more tasks read some shared data, the last result depends on the precise timing of the task run, which is possible to get the error value, so you must make sure to make sure when a task is used when using a shared variable or file. Other tasks cannot do the same operation. Mainly relevant to interruption, seize the prohibition and use of semaphore lock resources. In general, the interrupt is the most effective way to solve the mutual exclusion. But this is for real-time applications that prevent the system from responding to external events and cannot meet real-time requirements. Similarly, the interrupt delay is also unacceptable.
1.1.3. Semic
The VxWorks semaphore provides the fastest task communication mechanism, which is mainly used to resolve mutual exclusion and synchronization between tasks. For different types of problems, there are three sections:
Ÿ 二 The binary semaphore is the fastest and most extensive, mainly for synchronous or mutual exclusion;
Ÿ The amount of mutual exclusion signal is mainly used for priority inheritance, safe deletion, and retract;
Ÿ counter counter
VxWorks also provides POSIX semaphores and applications for signal quantities on multiprocessors.
1.1.1. Message Queue
Real-time applications consist of a series of tasks that are independently and collaborative work. The amount of semaphore provides an efficient method for synchronous and interlocking between tasks. The transfer of the task between tasks in a single processor uses a message message queue. The message mechanism uses a message queue shared by each related process, and the task is sent and received via this message queue.
Task full duplex information transmission
1.1.2. Pipeline
The pipe provides a flexible message transfer mechanism with VxWorks's I / O system, which is a virtual I / O device managed by the drive PiPedRV (provided by VxWorks). The task can call the standard I / O function to open, read, and write the pipe. When the task is trying to read data from an empty pipe, or when writing data into a full pipe, the task is blocked. Similar to the message queue, ISR can write information to the pipe, but cannot be read from it. Like I / O devices, the pipe has a message queue not as possible - calling Select (), task waiting for data on a series of I / O devices.
1.1.3. System implementation
The Wind Semic Quantity provides the same standardized interface for the control of various types of semaphors, and only the creation functions should specifically specify the type of semaphore.
SEMBCREATE () creates (generated and activated) a binary semaphore
Semmcreate () creates (generated and activated) a mutually exclusive quantity
Semccreate () creates (generated and activated) to make a count semaphore
SEMDELETE () abort and free semaphore
Semtake () Get the semity semgive () gives the quantity
Semflush () unlocks all tasks that are waiting for a certain session
Wind Message Queuing Management:
Msgqcreate () Create (Generate and activate) Message Queue
Msgqdelete () abort and free semaphore
Msgqsend () Send a message to the Message queue
MsgqRecEive () receives messages from message queue