📄 artx_ex1.c
字号:
/*----------------------------------------------------------------------------
* A R T X K e r n e l E x a m p l e
*----------------------------------------------------------------------------
* Name: ARTX_EX1.C
* Purpose: Your First Advanced RTX example program
* Rev.: V2.02 / 6-feb-2006
*----------------------------------------------------------------------------
* This code is part of the ARTX-ARM kernel package of Keil Software.
* Copyright (c) 2004-2006 Keil Software. All rights reserved.
*---------------------------------------------------------------------------*/
#include <ARTX.h> /* ARTX kernel functions & defines */
/* id1, id2 will contain task identifications at run-time */
OS_TID id1, id2;
/* Forward reference */
void task1 (void) __task;
void task2 (void) __task;
/*----------------------------------------------------------------------------
* Task 1: ARTX Kernel starts this task with os_sys_init (task1)
*---------------------------------------------------------------------------*/
void task1 (void) __task {
/* Obtain own system task identification number */
id1 = os_tsk_self ();
/* Assign system identification number of task2 to id2 */
id2 = os_tsk_create (task2, 1);
for (;;) { /* do-this */
/* Indicate to task2 completion of do-this */
os_evt_set (0x0004, id2);
/* Wait for completion of do-that (0xffff means no time-out)*/
os_evt_wait_or (0x0004, 0xffff);
/* Wait now for 50 ms */
os_dly_wait (5);
}
}
/*----------------------------------------------------------------------------
* Task 2: ARTX Kernel starts this task with os_tsk_create (task2, 1)
*---------------------------------------------------------------------------*/
void task2 (void) __task {
for (;;) {
/* Wait for completion of do-this (0xffff means no time-out) */
os_evt_wait_or (0x0004, 0xffff); /* do-that */
/* Pause for 20 ms until signaling event to task1 */
os_dly_wait (2);
/* Indicate to task1 completion of do-that */
os_evt_set (0x0004, id1);
}
}
/*----------------------------------------------------------------------------
* Main: Initialize and start ARTX Kernel
*---------------------------------------------------------------------------*/
void main (void) {
#ifdef MCB2100
U32 volatile start;
/* Wait for debugger connection (about 0.3 sec) */
for (start = 0; start < 1000000; start++) { ; }
#endif
os_sys_init (task1);
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -