适配系统适配层的更新
This commit is contained in:
@@ -192,16 +192,11 @@ int has_sem_deinit(has_sem_t *sem)
|
||||
}
|
||||
|
||||
/* ------------------------------------------------ 线程创建API ------------------------------------------------ */
|
||||
int has_task_create(const char *task_name, int priority, unsigned int stack_size,
|
||||
has_taskentry pfnEntry, void *pEntryParm, OS_THREAD_ID *pthread_id)
|
||||
int has_task_create(const has_task_attr_t *task_attr, OS_THREAD_ID *thread_id)
|
||||
{
|
||||
(void)task_name;
|
||||
(void)priority;
|
||||
(void)stack_size;
|
||||
(void)pfnEntry;
|
||||
(void)pEntryParm;
|
||||
if (pthread_id != NULL) {
|
||||
*pthread_id = NULL;
|
||||
(void)task_attr;
|
||||
if (thread_id != NULL) {
|
||||
*thread_id = NULL;
|
||||
}
|
||||
port_printf("has_task_create is not implemented for HAS_OS_USER_DEFINED.\n");
|
||||
return -1;
|
||||
@@ -209,9 +204,14 @@ int has_task_create(const char *task_name, int priority, unsigned int stack_size
|
||||
|
||||
int has_task_delete(OS_THREAD_ID thread_id)
|
||||
{
|
||||
#if HAS_ENABLE_FORCE_TASK_DELETE
|
||||
(void)thread_id;
|
||||
port_printf("has_task_delete is not implemented for HAS_OS_USER_DEFINED.\n");
|
||||
return -1;
|
||||
#else
|
||||
(void)thread_id;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64_t has_get_time_ms(void)
|
||||
@@ -244,12 +244,10 @@ void has_sleep_ms(uint32_t ms)
|
||||
// }
|
||||
}
|
||||
|
||||
int has_task_exit(OS_THREAD_ID task_id, uint32_t dw_cookie)
|
||||
void has_task_exit(void)
|
||||
{
|
||||
(void)task_id;
|
||||
(void)dw_cookie;
|
||||
port_printf("has_task_exit is not implemented for HAS_OS_USER_DEFINED.\n");
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,12 +3,10 @@
|
||||
|
||||
#include "has_platform_config.h"
|
||||
|
||||
|
||||
#if defined(HAS_OS_USER_DEFINED)
|
||||
|
||||
#define HAS_ENABLE_MUTEX_SEM // 支持互斥量和信号量
|
||||
|
||||
|
||||
/* 下面示例是基于xr806移植 */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -20,16 +18,45 @@
|
||||
|
||||
#define has_mutex_t OS_Mutex_t
|
||||
#define has_sem_t OS_Semaphore_t
|
||||
|
||||
#define TASK_PRIORITY_SYS 0
|
||||
#define TASK_PRIORITY_HIGH 1
|
||||
#define TASK_PRIORITY_LOW 8
|
||||
#define TASK_PRIORITY_NORMAL 4
|
||||
#define TASK_PRIORITY_ABOVE_NORMAL 3
|
||||
#define TASK_PRIORITY_BELOW_NORMAL 6
|
||||
typedef void *OS_THREAD_ID;
|
||||
typedef void *(*has_taskentry)(void *param);
|
||||
|
||||
typedef void (*has_task_entry_t)(void *param);
|
||||
|
||||
typedef enum {
|
||||
HAS_TASK_PRIORITY_SYS = 0,
|
||||
HAS_TASK_PRIORITY_HIGH,
|
||||
HAS_TASK_PRIORITY_ABOVE_NORMAL,
|
||||
HAS_TASK_PRIORITY_NORMAL,
|
||||
HAS_TASK_PRIORITY_BELOW_NORMAL,
|
||||
HAS_TASK_PRIORITY_LOW,
|
||||
} has_task_priority_t;
|
||||
|
||||
typedef struct {
|
||||
int32_t sched_policy; /* -1: use OS default */
|
||||
} has_task_linux_attr_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t reserved; /* reserved for future FreeRTOS-specific options */
|
||||
} has_task_freertos_attr_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t tick; /* 0: use default time slice */
|
||||
} has_task_rtthread_attr_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
has_task_entry_t entry;
|
||||
void *arg;
|
||||
uint32_t stack_size_bytes;
|
||||
has_task_priority_t priority;
|
||||
has_task_linux_attr_t linux_attr;
|
||||
has_task_freertos_attr_t freertos_attr;
|
||||
has_task_rtthread_attr_t rtthread_attr;
|
||||
} has_task_attr_t;
|
||||
|
||||
#ifndef HAS_ENABLE_FORCE_TASK_DELETE
|
||||
#define HAS_ENABLE_FORCE_TASK_DELETE 0
|
||||
#endif
|
||||
|
||||
#ifdef HAS_ENABLE_MUTEX_SEM
|
||||
enum MSG_WAIT_RET{
|
||||
@@ -61,9 +88,9 @@ int has_sem_deinit(has_sem_t *sem);
|
||||
#define has_sem_deinit(s)
|
||||
#endif
|
||||
|
||||
int has_task_create(const char *task_name, int priority, unsigned int stack_size,
|
||||
has_taskentry pfnEntry, void *pEntryParm, OS_THREAD_ID *pthread_id);
|
||||
int has_task_exit(OS_THREAD_ID task_id, uint32_t dw_cookie);
|
||||
int has_task_create(const has_task_attr_t *attr, OS_THREAD_ID *thread_id);
|
||||
void has_task_exit(void);
|
||||
/* Compatibility-only API: prefer cooperative stop + return/has_task_exit(). */
|
||||
int has_task_delete(OS_THREAD_ID thread_id);
|
||||
uint64_t has_get_time_ms(void);
|
||||
void has_sleep_ms(uint32_t ms);
|
||||
|
||||
Reference in New Issue
Block a user