Skip to main content

Posts

Showing posts from October, 2008

Virtual Sockets and Remote Procedure Call (RPC)

Virtual Sockets Tasks or section of Tasks can communicate with another task or section of task The tasks may send or receive the stream of bytes or datagram to communicate with each other It 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 Set Similarly, the Section I Portion of Task A is communicating with Section J of Task B. Remote Procedure Call (RPC) When a Task1 at 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 (IPC)

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)

Mailboxes (IPC)

Mailboxes 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 display There are three forms of Mailboxes most of the RTOS supports 1. One Message per box 2. Multiple messages queuing up 3. 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 Problem or Problems with Semaphores

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 deadlocks Suppose 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 function A semaphore is not taken as another task uses a shared variable A wrong semaphore is taken by a task There may be priority inversion problem Deadlocks Suppose if there are two semaphores S1 and S2, and there are two tasks T1 and T2. The locking will be in the following cycle T1-> S1 -> S2-> T1 T2 -> S2 -> S1 -> T2 The 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 execution Task T1 locks S1 and waiting for S2 which is been locked by T

Semaphores

In the above Diagram, The Task A Requesting for taking semaphore with the Kernel or Operating System The kernel acknowledge and ask task A to take the semaphore During that time Task B is Blocked (which also uses the same semphore) Task A Releases the semaphore, Event to the OS Task B starts running by taking the semaphore Use of Multiple Semaphores Two semaphores X and Y are used Task I, J and M share the semaphore X Task K and L Share the semaphore Y In the above diagram, the tasks J and M are waiting for taking the semaphore X as the semaphore is locked by the Task J similarly, the other semaphore Y is been locked by Task L and hence Task K is waiting

Shared data Problems and its solutions

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 function reentrant 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 secti

Message Queues (IPC)

Message Queues Either one task or group of tasks can use the queue Usually queue is circular. elements are accessed by means of FIFO. Printer task is an example Queue Initialization before using the function provision for multiple queues. each queue will be having an ID size of the queue is either user defined or predefined by the scheduler There may be a need for error handler, when a queue is full.

Signals

Signals Signal is a short message sent from a process for enabling inter process communication Signal is usually a one bit output comes from a process signal takes a shortest possible CPU time unlike Semaphores. Signals are useful for handling exceptions Whenever 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

Inter Process Communication (IPC)

Interprocess Communication (IPC) A process (task or ISR) generates an input information by setting or resetting a flag or value or generates an output, which will be used by some other process. Various techniques behind IPC are Signals Semaphores (Counting semaphore or binary semaphores) Message Queues, Mailboxes and Pipes Virtual Sockets Remote Procedure calls (RPC) for distributed Processes