int main (void) { // program execution starts here
if (osKernelInitialize () != osOK) { // initialize RTOS kernel
// invoke system error function
}
system_initialize (); // setup and initialize peripherals
osThreadCreate (osThread(job1)); // create threads
osThreadCreate (osThread(job2));
if (osKernelStart () != osOK) { // start kernel with job2 execution
// invoke system error function
}
while(1);
}
照着上面写的,可总是运行到while(1)那,两个任务job1,job2硬件仿真时看os里面根本就没这2个任务,就Ready状态的一idle任务
和一个处于等待timer任务
------解决思路----------------------
在 osKernelStart () 之后创建任务...
------解决思路----------------------
Keil自带有OS了?
------解决思路----------------------
要license的呀!
------解决思路----------------------
参考一下这个例程
#include "cmsis_os.h"
void Thread_1 (void const *arg); // function prototype for Thread_1
osThreadDef (Thread_1, osPriorityNormal, 1, 0); // define Thread_1
void ThreadCreate_example (void) {
osThreadId id;
id = osThreadCreate (osThread (Thread_1), NULL); // create the thread
if (id == NULL) { // handle thread creation
// Failed to create a thread
}
:
osThreadTerminate (id); // stop the thread
}
看一下官网的介绍:
http://www.keil.com/pack/doc/cmsis/rtos/html/group___c_m_s_i_s___r_t_o_s___thread_mgmt.html