Virtual SocketsTasks or section of Tasks can communicate with another task or section of taskThe tasks may send or receive the stream of bytes or datagram to communicate with each otherIt is similar like IP Address / Port. In the above diagram, Task C in the Task Set is communicating with Task D in the Same Task SetSimilarly, the Section I Portion of Task A is communicating with Section J of Task B. Remote Procedure Call (RPC) When a Task1at System 1 and Task2 at System 2, then Remote Procedure call is used.RPC Will be used only when both the systems are connected peer to peer but not in client server mode
Pipes are similar like message queues A pipe can be opened or closed similar like a fopen() and fclose() of a C Program A Task can write through a scheduler to a pipe at the back pointer address (*pBACK) A Task can read through a scheduler to a pipe at the front pointer address (*pFRONT)
A Meassage mailbox is an IPC message Block that can be used only by a single destined Task The source is the task that sends the message pointer to a created mailbox. Example is the Mobile phone LCD Multiline display task in which the time and list of phone number displayed on a single displayThere are three forms of Mailboxes most of the RTOS supports1. One Message per box2. Multiple messages queuing up3. Multiple messages with a priority value (According to the priority values, the insertion happens at the middle and reading or deleting happens at the front of the queue)
Elimination of Shared Data Problems or Problems with Semaphores
The use of semaphores does not eliminate the shared data problem completely.
So there are some problems when using semaphores Sharing of two semaphores leads to deadlocksSuppose that the locked semaphore is not released? There should be some timeout interval in which after the timeout the Watch Dog Timer will reset the processor thereby the error is handled by a functionA semaphore is not taken as another task uses a shared variableA wrong semaphore is taken by a taskThere may be priority inversion problemDeadlocksSuppose if there are two semaphores S1 and S2, and there are two tasks T1 and T2. The locking will be in the following cycleT1-> S1 -> S2-> T1 T2 -> S2 -> S1 -> T2The above two scenarios, both the Tasks T1 and T2 needs to take the semaphores S1 and S2. Both the tasks wont release the semaphores until it completes the executionTask T1 locks S1 and waiting for S2 which is been locked by T2. similarl…
In the above Diagram, The Task A Requesting for taking semaphore with the Kernel or Operating SystemThe kernel acknowledge and ask task A to take the semaphoreDuring that time Task B is Blocked (which also uses the same semphore)Task A Releases the semaphore, Event to the OSTask B starts running by taking the semaphore Use of Multiple SemaphoresTwo semaphores X and Y are usedTask I, J and M share the semaphore X Task K and L Share the semaphore YIn the above diagram, the tasks J and M are waiting for taking the semaphore X as the semaphore is locked by the Task Jsimilarly, the other semaphore Y is been locked by Task L and hence Task K is waiting
Assume that several ISRs or tasks share a variable. If there is a variable currently running under a task and there is an interrupt and some other task will be taking the control of that variable. Since the variable is already used by other task, so there comes a shared data problem. The bugs encountered in the above process can be eliminated by means of following techniques use of volatile modifier - this declaration warns the compiler that certain variables can modify because the ISR does not consider the fact that the variable is also shared with a calling functionreentrant function - part of a function that needs its complete execution before it can be interrupted. This part is called the critical section.put a shared variable in a circular queue - a function that requires the value of this variable always delete it from the queue front and another function which inserts the value of this variable,a lways does so at the queue back.Disabling the interrupts before a critical section s…
Message Queues Either one task or group of tasks can use the queueUsually queue is circular. elements are accessed by means of FIFO.Printer task is an exampleQueue Initialization before using the functionprovision for multiple queues. each queue will be having an IDsize of the queue is either user defined or predefined by the schedulerThere may be a need for error handler, when a queue is full.
Signals Signal is a short message sent from a process for enabling inter process communicationSignal is usually a one bit output comes from a processsignal takes a shortest possible CPU time unlike Semaphores.Signals are useful for handling exceptionsWhenever there is an error during a running of process, a signal is generated thereby the scheduler schedules a process to handle that error, in this way signals are used extensively for error and exception handling