1 /* 2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited 3 */ 4 5 #ifndef K_OBJ_H 6 #define K_OBJ_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 /** @addtogroup aos_rhino obj 13 * Internal object information 14 * 15 * @{ 16 */ 17 18 /** 19 * Blocking strategy. 20 * It determines which task can go first when they are waiting for one resource.(from 'pend' to 'ready') 21 * BLK_POLICY_PRI is default. 22 */ 23 typedef enum { 24 /** 25 * High-priority tasks are easier to obtain resources, the same priority is in FIFO order. 26 */ 27 BLK_POLICY_PRI = 0u, 28 /** 29 * Just in FIFO order. 30 */ 31 BLK_POLICY_FIFO 32 } blk_policy_t; 33 34 /** 35 * Reasons for the end of the blocking state 36 */ 37 typedef enum { 38 BLK_FINISH = 0, /**< task blocking successfully */ 39 BLK_ABORT, /**< task blocking is aborted */ 40 BLK_TIMEOUT, /**< task blocking timeout */ 41 BLK_DEL, /**< task blocking for a deleted 'obj' */ 42 BLK_INVALID 43 } blk_state_t; 44 45 /** 46 * The objects types 47 */ 48 typedef enum { 49 RHINO_OBJ_TYPE_NONE = 0, 50 RHINO_SEM_OBJ_TYPE, 51 RHINO_MUTEX_OBJ_TYPE, 52 RHINO_QUEUE_OBJ_TYPE, 53 RHINO_BUF_QUEUE_OBJ_TYPE, 54 RHINO_TIMER_OBJ_TYPE, 55 RHINO_EVENT_OBJ_TYPE, 56 RHINO_MM_OBJ_TYPE 57 } kobj_type_t; 58 59 /** 60 * Abstract model of the 'obj': 61 * 'obj' is an abstraction of all types of objects that can cause task blocking 62 * (that is, tasks waiting for the resource to enter the PEND state). 63 */ 64 typedef struct blk_obj { 65 klist_t blk_list; /**< Manage blocked tasks */ 66 const name_t *name; 67 blk_policy_t blk_policy; 68 kobj_type_t obj_type; 69 #if (RHINO_CONFIG_USER_SPACE > 0) 70 klist_t obj_list; 71 #endif 72 #if (RHINO_CONFIG_TASK_DEL > 0) 73 uint8_t cancel; 74 #endif 75 } blk_obj_t; 76 77 /** 78 * Records multiple types of objects created by the OS, each type forming a linked list 79 */ 80 typedef struct { 81 klist_t task_head; 82 klist_t mutex_head; 83 84 #if (RHINO_CONFIG_SEM > 0) 85 klist_t sem_head; 86 #endif 87 88 #if (RHINO_CONFIG_QUEUE > 0) 89 klist_t queue_head; 90 #endif 91 92 #if (RHINO_CONFIG_EVENT_FLAG > 0) 93 klist_t event_head; 94 #endif 95 96 #if (RHINO_CONFIG_BUF_QUEUE > 0) 97 klist_t buf_queue_head; 98 #endif 99 } kobj_list_t; 100 101 /** @} */ 102 103 #ifdef __cplusplus 104 } 105 #endif 106 107 #endif /* K_OBJ_H */ 108 109