/*
*********************************************************************************************************
* uC/OS-II
* The Real-Time Kernel
* CORE FUNCTIONS
*
* (c) Copyright 1992-2005, Jean J. Labrosse, Weston, FL
* All Rights Reserved
*
* File : OS_CORE.C
* By : Jean J. Labrosse
* Version : V2.80
*********************************************************************************************************
*/
#ifndef OS_MASTER_FILE
#define OS_GLOBALS
#include "ucos_ii.h"
#endif
/*
*********************************************************************************************************
* PRIORITY RESOLUTION TABLE
*
* Note: Index into table is bit pattern to resolve highest priority
* Indexed value corresponds to highest priority bit position (i.e. 0..7)
*********************************************************************************************************
*/
INT8U const OSUnMapTbl[256] = {
0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x00 to 0x0F */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x10 to 0x1F */
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x20 to 0x2F */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x30 to 0x3F */
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x40 to 0x4F */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x50 to 0x5F */
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x60 to 0x6F */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x70 to 0x7F */
7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x80 to 0x8F */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0x90 to 0x9F */
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xA0 to 0xAF */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xB0 to 0xBF */
6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xC0 to 0xCF */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xD0 to 0xDF */
5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, /* 0xE0 to 0xEF */
4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 /* 0xF0 to 0xFF */
};
/*$PAGE*/
/*
*********************************************************************************************************
* FUNCTION PROTOTYPES
*********************************************************************************************************
*/
static void OS_InitEventList(void);
static void OS_InitMisc(void);
static void OS_InitRdyList(void);
static void OS_InitTaskIdle(void);
#if OS_TASK_STAT_EN > 0
static void OS_InitTaskStat(void);
#endif
static void OS_InitTCBList(void);
static void OS_SchedNew(void);
/*$PAGE*/
/*
*********************************************************************************************************
* GET THE NAME OF A SEMAPHORE, MUTEX, MAILBOX or QUEUE
*
* Description: This function is used to obtain the name assigned to a semaphore, mutex, mailbox or queue.
*
* Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore,
* a mutex, a mailbox or a queue. Where this function is concerned, the actual
* type is irrelevant.
*
* pname is a pointer to an ASCII string that will receive the name of the semaphore,
* mutex, mailbox or queue. The string must be able to hold at least
* OS_EVENT_NAME_SIZE characters.
*
* err is a pointer to an error code that can contain one of the following values:
*
* OS_NO_ERR if the name was copied to 'pname'
* OS_ERR_EVENT_TYPE if 'pevent' is not pointing to the proper event
* control block type.
* OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
* OS_ERR_PEVENT_NULL if you passed a NULL pointer for 'pevent'
*
* Returns : The length of the string or 0 if the 'pevent' is a NULL pointer.
*********************************************************************************************************
*/
#if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
INT8U OSEventNameGet (OS_EVENT *pevent, INT8U *pname, INT8U *err)
{
INT8U len;
#if OS_CRITICAL_METHOD == 3 /* Allocate storage for CPU status register */
OS_CPU_SR cpu_sr = 0;
#endif
#if OS_ARG_CHK_EN > 0
if (err == (INT8U *)0) { /* Validate 'err' */
return (0);
}
if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer? */
*err = OS_ERR_PEVENT_NULL;
return (0);
}
if (pname == (INT8U *)0) { /* Is 'pname' a NULL pointer? */
*err = OS_ERR_PNAME_NULL;
return (0);
}
#endif
switch (pevent->OSEventType) {
case OS_EVENT_TYPE_SEM:
case OS_EVENT_TYPE_MUTEX:
case OS_EVENT_TYPE_MBOX:
case OS_EVENT_TYPE_Q:
break;
default:
*err = OS_ERR_EVENT_TYPE;
return (0);
}
OS_ENTER_CRITICAL();
len = OS_StrCopy(pname, pevent->OSEventName); /* Copy name from OS_EVENT */
OS_EXIT_CRITICAL();
*err = OS_NO_ERR;
return (len);
}
#endif
/*$PAGE*/
/*
*********************************************************************************************************
* ASSIGN A NAME TO A SEMAPHORE, MUTEX, MAILBOX or QUEUE
*
* Description: This function assigns a name to a semaphore, mutex, mailbox or queue.
*
* Arguments : pevent is a pointer to the event group. 'pevent' can point either to a semaphore,
* a mutex, a mailbox or a queue. Where this function is concerned, it doesn't
* matter the actual type.
*
* pname is a pointer to an ASCII string that will be used as the name of the semaphore,
* mutex, mailbox or queue. The string must be able to hold at least
* OS_EVENT_NAME_SIZE characters.
*
* err is a pointer to an error code that can contain one of the following values:
*
* OS_NO_ERR if the requested task is resumed
* OS_ERR_EVENT_TYPE if 'pevent' is not pointing to the proper event
* control block type.
* OS_ERR_PNAME_NULL You passed a NULL pointer for 'pname'
* OS_ERR_PEVENT_NULL if you passed a NULL pointer for 'pevent'
*
* Returns : None
*********************************************************************************************************
*/
#if OS_EVENT_EN && (OS_EVENT_NAME_SIZE > 1)
void OSEventNameSet (OS_EVENT *pevent, INT8U *pname, INT8U *err)
{
INT8U len;
#if OS_CRITICAL_ME
林当时
- 粉丝: 114
- 资源: 1万+
最新资源
- 【流体】基于matlab纳维-斯托克斯方程模拟平板上的超音速流动【含Matlab源码 10954期】.zip
- 【化工】基于matlab端点模型预测控制器MPC控制青霉素和CHO细胞生产多变量【含Matlab源码 10953期】.zip
- 【光学】基于matlab计算石墨烯非线性光带和自激类克尔效应【含Matlab源码 10952期】.zip
- 【流体学】基于matlab求解粘性流体通过矩形管道流动的速度扩散【含Matlab源码 10955期】.zip
- 【数据驱动】基于matlab化学势场制定稳态和瞬态质量扩散问题【含Matlab源码 10946期】.zip
- 【数据驱动】基于matlab Koopman算子理论对恒化器模型数据驱动【含Matlab源码 10937期】.zip
- 【数据驱动】基于matlab数据驱动GGM-ET-PHD滤波器【含Matlab源码 10941期】.zip
- 【数据驱动】基于matlab数据驱动的最大轮胎道路摩擦系数预测【含Matlab源码 10945期】.zip
- 【数据驱动】基于matlab数据驱动BORM仿真【含Matlab源码 10940期】.zip
- 【数据驱动】基于matlab数据驱动模型预测控制MPC(闭环保证)【含Matlab源码 10944期】.zip
- 【数据驱动】基于matlab数据驱动动态系统分析的流形学习【含Matlab源码 10943期】.zip
- 【数据驱动】基于matlab四维随机射弹系统的数据驱动建模【含Matlab源码 10947期】.zip
- 【数据驱动】基于matlab系统识别工具箱实时数据驱动控制【含Matlab源码 10938期】.zip
- 【图像分割】基于matlab数字形态学数字视网膜图像血管提取DRIVE数据集分割【含Matlab源码 10948期】.zip
- 【湍流】基于matlab模拟高斯光束通过大气湍流相位屏【含Matlab源码 10956期】.zip
- 毕业设计部署yolov9模型ncnn模型到树莓派4或5嵌入式C++源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈