ucos操作系统源码

  • P1_344137
    了解作者
  • 90.9KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-05-22 01:49
    上传日期
ucos操作系统源代码,微内核,在嵌入式领域占很大的比例
ucos2.zip
  • Source
  • os_time.c
    11KB
  • os_core.c
    86.3KB
  • os_flag.c
    54.7KB
  • ucos_ii.h
    77.5KB
  • os_q.c
    41.5KB
  • os_sem.c
    28.8KB
  • os_mbox.c
    30.4KB
  • os_cfg_r.h
    10.5KB
  • os_tmr.c
    44KB
  • os_dbg_r.c
    12.7KB
  • os_mutex.c
    37KB
  • os_task.c
    56.4KB
  • ucos_ii.c
    1.6KB
  • os_mem.c
    19.3KB
内容介绍
/* ********************************************************************************************************* * uC/OS-II * The Real-Time Kernel * CORE FUNCTIONS * * (c) Copyright 1992-2009, Micrium, Weston, FL * All Rights Reserved * * File : OS_CORE.C * By : Jean J. Labrosse * Version : V2.91 * * LICENSING TERMS: * --------------- * uC/OS-II is provided in source form for FREE evaluation, for educational use or for peaceful research. * If you plan on using uC/OS-II in a commercial product you need to contact Micri�m to properly license * its use in your product. We provide ALL the source code for your convenience and to help you experience * uC/OS-II. The fact that the source is provided does NOT mean that you can use it without paying a * licensing fee. ********************************************************************************************************* */ #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] = { 0u, 0u, 1u, 0u, 2u, 0u, 1u, 0u, 3u, 0u, 1u, 0u, 2u, 0u, 1u, 0u, /* 0x00 to 0x0F */ 4u, 0u, 1u, 0u, 2u, 0u, 1u, 0u, 3u, 0u, 1u, 0u, 2u, 0u, 1u, 0u, /* 0x10 to 0x1F */ 5u, 0u, 1u, 0u, 2u, 0u, 1u, 0u, 3u, 0u, 1u, 0u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, 1u, 0u, 2u, 0u, 1u, 0u /* 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 > 0u 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 a pointer to an ASCII string that will receive the name of the semaphore, * mutex, mailbox or queue. * * perr is a pointer to an error code that can contain one of the following values: * * OS_ERR_NONE 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' * OS_ERR_NAME_GET_ISR if you are trying to call this function from an ISR * * Returns : The length of the string or 0 if the 'pevent' is a NULL pointer. ********************************************************************************************************* */ #if (OS_EVENT_EN) && (OS_EVENT_NAME_EN > 0u) INT8U OSEventNameGet (OS_EVENT *pevent, INT8U **pname, INT8U *perr) { INT8U len; #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register */ OS_CPU_SR cpu_sr = 0u; #endif #ifdef OS_SAFETY_CRITICAL if (perr == (INT8U *)0) { OS_SAFETY_CRITICAL_EXCEPTION(); } #endif #if OS_ARG_CHK_EN > 0u if (pevent == (OS_EVENT *)0) { /* Is 'pevent' a NULL pointer? */ *perr = OS_ERR_PEVENT_NULL; return (0u); } if (pname == (INT8U **)0) { /* Is 'pname' a NULL pointer? */ *perr = OS_ERR_PNAME_NULL; return (0u); } #endif if (OSIntNesting > 0u) { /* See if trying to call from an ISR */ *perr = OS_ERR_NAME_GET_ISR; return (0u); } 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: *perr = OS_ERR_EVENT_TYPE; return (0u); } OS_ENTER_CRITICAL(); *pname = pevent->OSEventName; len = OS_StrLen(*pname); OS_EXIT_CRITICAL(); *perr = OS_ERR_NONE; 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. * * perr is a pointer to an error code that can contain one of the following values: * * OS_ERR_NONE if the requested task is resumed * OS_ERR_EVENT_TYPE
评论
    相关推荐