eric2013 发表于 2022-10-28 01:07:38

RTX5的信号量控制块没有做列表,就是独立的一个结构体变量,没法做遍历操作



信号量列表创建太简单了,没有做列表管理

/// Create and Initialize a Semaphore object.
/// \note API identical to osSemaphoreNew
static osSemaphoreId_t svcRtxSemaphoreNew (uint32_t max_count, uint32_t initial_count, const osSemaphoreAttr_t *attr) {
os_semaphore_t *semaphore;
uint8_t         flags;
const char   *name;

// Check parameters
if ((max_count == 0U) || (max_count > osRtxSemaphoreTokenLimit) || (initial_count > max_count)) {
    EvrRtxSemaphoreError(NULL, (int32_t)osErrorParameter);
    //lint -e{904} "Return statement before end of function"
    return NULL;
}

// Process attributes
if (attr != NULL) {
    name      = attr->name;
    //lint -e{9079} "conversion from pointer to void to pointer to other type"
    semaphore = attr->cb_mem;
    if (semaphore != NULL) {
      //lint -e(923) -e(9078) "cast from pointer to unsigned int"
      if ((((uint32_t)semaphore & 3U) != 0U) || (attr->cb_size < sizeof(os_semaphore_t))) {
      EvrRtxSemaphoreError(NULL, osRtxErrorInvalidControlBlock);
      //lint -e{904} "Return statement before end of function"
      return NULL;
      }
    } else {
      if (attr->cb_size != 0U) {
      EvrRtxSemaphoreError(NULL, osRtxErrorInvalidControlBlock);
      //lint -e{904} "Return statement before end of function"
      return NULL;
      }
    }
} else {
    name      = NULL;
    semaphore = NULL;
}

// Allocate object memory if not provided
if (semaphore == NULL) {
    if (osRtxInfo.mpi.semaphore != NULL) {
      //lint -e{9079} "conversion from pointer to void to pointer to other type"
      semaphore = osRtxMemoryPoolAlloc(osRtxInfo.mpi.semaphore);
    } else {
      //lint -e{9079} "conversion from pointer to void to pointer to other type"
      semaphore = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_semaphore_t), 1U);
    }
#ifdef RTX_OBJ_MEM_USAGE
    if (semaphore != NULL) {
      uint32_t used;
      osRtxSemaphoreMemUsage.cnt_alloc++;
      used = osRtxSemaphoreMemUsage.cnt_alloc - osRtxSemaphoreMemUsage.cnt_free;
      if (osRtxSemaphoreMemUsage.max_used < used) {
      osRtxSemaphoreMemUsage.max_used = used;
      }
    }
#endif
    flags = osRtxFlagSystemObject;
} else {
    flags = 0U;
}

if (semaphore != NULL) {
    // Initialize control block
    semaphore->id          = osRtxIdSemaphore;
    semaphore->flags       = flags;
    semaphore->name      = name;
    semaphore->thread_list = NULL;
    semaphore->tokens      = (uint16_t)initial_count;
    semaphore->max_tokens= (uint16_t)max_count;

    // Register post ISR processing function
    osRtxInfo.post_process.semaphore = osRtxSemaphorePostProcess;

    EvrRtxSemaphoreCreated(semaphore, semaphore->name);
} else {
    EvrRtxSemaphoreError(NULL,(int32_t)osErrorNoMemory);
}

return semaphore;
}

eric2013 发表于 2022-10-30 01:42:04

如果全局动态创建方式,找到检索办法了,可以从全局动态内存里面动态检索。
页: [1]
查看完整版本: RTX5的信号量控制块没有做列表,就是独立的一个结构体变量,没法做遍历操作