Higher priority
Task a_tsk(void)
{
While(1) {
bp1
cwai_flg(FLG_1) ;
printf("%s,a_msg) ;
}
}
Lower priority
Task b_tsk(void)
{
While(1) {
bp2
printf("%s",b_msg) ;
set_flg(FLG_1) ;
}
}
(2) Run the sample system to the point immediately before set_flg of b_tsk (hereafter
expressed as the point immediately before bp2). Run the sample system by clicking on the
bp2 point shown in Figure Bk). HyperTerminal will then display " hello, i am b_task. "
(3) Run the sample system to the point immediately before bp1 again. HyperTerminal will then
display " HE Lh Le01,1 oI, AiM aAm_ TbA_StKa.s ".
(4) Run the sample system to the point immediately before bp2 again. HyperTerminal will then
display "k. ".
(5) Repeat steps (3) and (4) above for output operation.
The data output by each task is set as follows:
a_tsk: " HELLO, I AM A_TASK. "
b_tsk: " hello, i am b_task. "
In step (5), the tasks look as if they are performing output operation alternately as shown in
Figure Bl.
cwai_flg(FLG_1);
printf("%s", b_msg);
set_flg(FLG_1);
printf("%s", b_msg);
cwai_flg(FLG_1);
Flag waiting
Flag set
Figure Bk Execution Breakpoints
*
Figure Bl
Task Operation
APPENDIX B Running the Sample System
Event flag ID = 1
Initial pattern
value 0
/* a_tsk */
/* b_tsk */
/* a_tsk */
/* b_tsk */
/* a_tsk */
47