#include "task_in.h"
#ifdef OS_MUTEX
/*
// ---------------- MUTUAL EXCLUSION SEMAPHORES ---------------
#define OS_MUTEX_EN 1 // Enable (1) or Disable (0) code generation for MUTEX
#define OS_MUTEX_ACCEPT_EN 1 // Include code for OSMutexAccept()
#define OS_MUTEX_DEL_EN 1 // Include code for OSMutexDel()
#define OS_MUTEX_QUERY_EN 1 // Include code for OSMutexQuery()
在os_cfg.h中,将上述编译开关打开
*/
#define MUTEX_PRIO 7
OS_EVENT *mutex;
void led();
void task1(void *pdata)
{
INT8U err;
pdata=pdata;
mutex=OSMutexCreate(MUTEX_PRIO,&err);
while(1)
{
led();
OSTimeDly(1000);
}
}
void task2(void *pdata)
{
pdata=pdata;
while(1)
{
led();
OSTimeDly(2000);
}
}
void task3(void *pdata)
{
pdata=pdata;
while(1)
{
OSTimeDly(1000);
}
}
void led()
{
INT8U err;
OSMutexPend(mutex,0,&err);
Led_Ctl(LED_RUN,1);
OSTimeDly(100);
Led_Ctl(LED_RUN,0);
OSTimeDly(200);
OSMutexPost(mutex);
}
#endif
阅读(4771) | 评论(0) | 转发(1) |