simple.c
来自「Philips ARM KPC2xxx series Real Time Ope」· C语言 代码 · 共 140 行
C
140 行
/****************************************************************************** * * Copyright: * (C) 2000 - 2005 Embedded Artists AB * * Description: * Sample application that demonstrates how to create processes. * *****************************************************************************/#include "../pre_emptive_os/api/osapi.h"#include "../pre_emptive_os/api/general.h"#include <printf_P.h>#include <ea_init.h>#define PROC1_STACK_SIZE 1024#define PROC2_STACK_SIZE 1024#define INIT_STACK_SIZE 1024static tU8 proc1Stack[PROC1_STACK_SIZE];static tU8 proc2Stack[PROC2_STACK_SIZE];static tU8 initStack[INIT_STACK_SIZE];static tU8 pid1;static tU8 pid2;static void proc1(void* arg);static void proc2(void* arg);static void initProc(void* arg);/***************************************************************************** * * Description: * The first function to execute * ****************************************************************************/intmain(void){ tU8 error; tU8 pid; osInit(); osCreateProcess(initProc, initStack, INIT_STACK_SIZE, &pid, 1, NULL, &error); osStartProcess(pid, &error); osStart(); return 0;}/***************************************************************************** * * Description: * A process entry function * * Params: * [in] arg - This parameter is not used in this application. * ****************************************************************************/static voidproc1(void* arg){ for(;;) { printf("Process: 1\n"); osSleep(50); }}/***************************************************************************** * * Description: * A process entry function. * * Params: * [in] arg - This parameter is not used in this application. * ****************************************************************************/static voidproc2(void* arg){ for(;;) { printf("Process: 2\n"); osSleep(160); }}/***************************************************************************** * * Description: * The entry function for the initialization process. * * Params: * [in] arg - This parameter is not used in this application. * ****************************************************************************/static voidinitProc(void* arg){ tU8 error; eaInit(); printf("\n*******************************************************\n"); printf("* *\n"); printf("* Welcome to the pre-emptive operating system from *\n"); printf("* Embedded Artists, for the LPC2xxx microcontroller. *\n"); printf("* *\n"); printf("* This is a sample application demonstrating how to *\n"); printf("* create and start processes. *\n"); printf("* *\n"); printf("*******************************************************\n"); osCreateProcess(proc1, proc1Stack, PROC1_STACK_SIZE, &pid1, 2, NULL, &error); osStartProcess(pid1, &error); osCreateProcess(proc2, proc2Stack, PROC2_STACK_SIZE, &pid2, 3, NULL, &error); osStartProcess(pid2, &error); osDeleteProcess();}/***************************************************************************** * * Description: * The timer tick entry function that is called once every timer tick * interrupt in the RTOS. Observe that any processing in this * function must be kept as short as possible since this function * execute in interrupt context. * * Params: * [in] elapsedTime - The number of elapsed milliseconds since last call. * ****************************************************************************/voidappTick(tU32 elapsedTime){}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?