12.07.2015 Views

EDA222/DIT161 – Real-Time Systems, Chalmers/GU, 2010/2011 ...

EDA222/DIT161 – Real-Time Systems, Chalmers/GU, 2010/2011 ...

EDA222/DIT161 – Real-Time Systems, Chalmers/GU, 2010/2011 ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>ADCSwitchTPADCSScreenDACprocedure Controller isTR : Temp_Reading;PR : Pressure_Reading;HS : Heater_Setting;PS : Pressure_Setting;beginloopRead(TR);-- read temperatureTemp_Convert(TR,HS); -- convert to temperature settingWrite(HS); -- to temperature switchWrite(TR); -- to screenRead(PR);-- read pressurePressure_Convert(PR,PS); -- convert to pressure settingWrite(PS); -- to pressure controlWrite(PR); -- to screenend loop;end Controller;5


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>Procedure Controller istask Temp_Controller;task Pressure_Controller;task body Temp_Controller isbeginloopRead(TR);Temp_Convert(TR,HS);Write(HS);Write(TR);end loop;end Temp_Controller;task body Pressure_Controller isbeginloopRead(PR);Pressure_Convert(PR,PS);Write(PS);Write(PR);end loop;end Pressure_Controller;beginnull; -- begin parallel executionend Controller;• A parallel code entity in Ada iscalled ”task”• A task consists of a specificationand a bodyProcedure Controller does not terminateuntil tasks Temp_Controller andPressure_Controller both have terminated7


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>9


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>Task YYSimple_BufferWriteTask ZReadZ10


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>task Simple_Buffer isentry Write(d : in data);entry Read(d : out data);end Simple_Buffer;task body Simple_Buffer isbuffer : data;beginloopaccept Write(d : in data) dobuffer := d; -- save client data in bufferend Write;accept Read(d : out data) dod := buffer; -- return buffer data to clientend Read;end loop;end Simple_Buffer;ADCSwitchTPADCSScreenDAC11


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>task Screen_Controller isentry Write_p(PR : in Pressure_Reading);entry Write_t(TR : in Temp_Reading);end Screen_Controller;task body Screen_Controller isbeginloopaccept Write_p(PR : in Pressure_Reading) doput_p(PR); -- write pressure value to screenend Write_p;accept Write_t(TR : in Temp_Reading) doput_t(TR); -- write temperature value to screenend Write_t;end loop;end Screen_Controller;Procedure Controller istask Temp_Controller;task Pressure_Controller;task body Temp_Controller isbeginloopRead(TR);Temp_Convert(TR,HS);Write(HS);Screen_Controller.Write_t(TR); -- entry callend loop;end Temp_Controller;task body Pressure_Controller isbeginloopRead(PR);Pressure_Convert(PR,PS);Write(PS);Screen_Controller.Write_p(PR); -- entry callend loop;end Pressure_Controller;beginnull; -- begin parallel executionend Controller;12


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>13


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>task Screen_Controller isentry Write_p(PR : in Pressure_Reading);entry Write_t(TR : in Temp_Reading);end Screen_Controller;task body Screen_Controller isbeginloopselectaccept Write_p(PR : in Pressure_Reading) doput_p(PR); -- write pressure value to screenend Write_p;oraccept Write_t(TR : in Temp_Reading) doput_t(TR); -- write temperature value to screenend Write_t;end select;end loop;end Screen_Controller;14


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>15


<strong>EDA222</strong>/<strong>DIT161</strong> – <strong>Real</strong>-<strong>Time</strong> <strong>Systems</strong>, <strong>Chalmers</strong>/<strong>GU</strong>, <strong>2010</strong>/<strong>2011</strong> Lecture #2Updated January 16, <strong>2011</strong>16

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!