job0 () _task_ 0 {
os_create_task (1); /* start task 1 */
os_create_task (2); /* start task 2 */
os_create_task (3); /* start task 3 */
while (1) { /* endless loop */
counter0++; /* increment counter 0 */
os_wait (K_TMO, 5, 0); /* wait for timeout: 5 ticks */
}
}
/******************************************************************************/
/* Task 1 'job1': RTX-51 tiny starts this task with os_create_task (1) */
/******************************************************************************/
job1 () _task_ 1 {
while (1) { /* endless loop */
counter1++; /* increment counter 1 */
os_wait (K_TMO, 10, 0); /* wait for timeout: 10 ticks */
}
}
/******************************************************************************/
/* Task 2 'job2': RTX-51 tiny starts this task with os_create_task (2) */
/******************************************************************************/
job2 () _task_ 2 {
while (1) { /* endless loop */
counter2++; /* increment counter 2 */
if ((counter2 & 0xFFFF) == 0) { /* signal overrun of counter 2*/
os_send_signal (3); /* to task 3 */
P2=os_clear_signal (3); //为什么运行完这句之后P2==0x01?不是返回0吗
}
}
}
/******************************************************************************/
/* Task 3 'job3': RTX-51 tiny starts this task with os_create_task (3) */
/******************************************************************************/
job3 () _task_ 3 {
while (1) { /* endless loop */
counter3++;
os_wait (K_SIG, 0, 0); /* wait for signal */
counter3++; /* process overflow from counter 2 */
}
}
|