Shared FIFO The asynchronous communication between real-time application's tasks is programmed by using a FIFO list (First
Question:
Shared FIFO The asynchronous communication between real-time application's tasks is programmed by using a FIFO list (First In - First Out). This list is implemented by a data structure composed of an array named Buffer of size Buffer_Size with two indexes Write_Index and Read_Index.
These indexes respectively represent the index of the first free place in the array, and index of the next character to read. In the zone of the array between Read_Index and Wr i te_Index-l, values are stored as shown in Figure 11.10.
We suppose that there is always at least one element in the array and that it is never full. This array is managed like a circular buffer. Thus, the access operations Write and Read are programmed by:
Procedure Write{X : in Element) is begin Buffer{Write_Index) := X;
Write_Index .- (Write_Index mod Buffer_Size) + 1;
end Write;
Procedure Read(X ; out Element) is begin X ;= Buffer(Read_Index);
Read_Index ;= (Read_Index mod Buffer_Size) + 1;
end Read;
Determine the state of the array when:
1. two calls to wri te happen at the same time (the statements of the body of the procedure Wri te are executed in an interwoven way);
2. a call to wri te and a call to Read happen at the same time (the statements of the bodies of the procedure Wr i te and Read are executed in an interwoven way).
What would you conclude about this programming of an asynchronous communication between two tasks?
Step by Step Answer:
Design Of Dependable Computing Systems
ISBN: 978-9048159413
1st Edition
Authors: J C Geffroy ,G Motet