13#ifndef __xwos_osal_thd_h__
14#define __xwos_osal_thd_h__
166#define XWOS_THD_NILD ((xwos_thd_d){NULL, 0,})
203#define __xwos_thd_stack __xwcc_alignl1cache
208#define XWOS_STACK_SIZE_DEFAULT XWMMCFG_STACK_SIZE_DEFAULT
213#define XWOS_STACK_SIZE_MIN XWMMCFG_STACK_SIZE_MIN
218#define XWOS_STACK_GUARD_SIZE_DEFAULT XWMMCFG_STACK_GUARD_SIZE_DEFAULT
223#define XWOS_THD_LOCAL_DATA_NUM XWOSDL_THD_LOCAL_DATA_NUM
255 xwosdl_thd_attr_init((
struct xwosdl_thd_attr *)attr);
298 return xwosdl_thd_init(&thd->
osthd, (xwosdl_thd_d *)thdd,
299 (
const struct xwosdl_thd_attr *)attr,
301 (xwosdl_thd_f)thdfunc, arg);
320 return xwosdl_thd_grab(&thdd.
thd->
osthd);
339 return xwosdl_thd_put(&thdd.
thd->
osthd);
370 return xwosdl_thd_create((xwosdl_thd_d *)thdd,
371 (
const struct xwosdl_thd_attr *)attr,
373 (xwosdl_thd_f)thdfunc, arg);
389 return xwosdl_thd_acquire(&thdd.
thd->
osthd, thdd.
tik);
405 return xwosdl_thd_release(&thdd.
thd->
osthd, thdd.
tik);
424 return xwosdl_thd_launch(&thdd.
thd->
osthd, thdd.
tik,
426 (xwosdl_thd_f)thdfunc, arg);
444 return xwosdl_thd_get_attr(&thdd.
thd->
osthd, thdd.
tik,
445 (
struct xwosdl_thd_attr *)attr);
463 struct xwosdl_thd_stack_info info;
465 rc = xwosdl_thd_get_stack_info(&thdd.
thd->
osthd, thdd.
tik, &info);
466 if ((
XWOK == rc) && (stack)) {
469 stack->
base = info.base;
470 stack->
size = info.size;
473 stack->
line = info.line;
474 stack->
usage = info.usage;
493 return xwosdl_thd_get_stack_usage(&thdd.
thd->
osthd, thdd.
tik, usage);
513 return xwosdl_thd_intr(&thdd.
thd->
osthd, thdd.
tik);
544 return xwosdl_thd_quit(&thdd.
thd->
osthd, thdd.
tik);
579 return xwosdl_thd_join(&thdd.
thd->
osthd, thdd.
tik, trc);
602 return xwosdl_thd_stop(&thdd.
thd->
osthd, thdd.
tik, trc);
624 return xwosdl_thd_detach(&thdd.
thd->
osthd, thdd.
tik);
646 return xwosdl_thd_migrate(&thdd.
thd->
osthd, thdd.
tik, dstcpu);
660 thdd = xwosdl_cthd_self();
729 xwosdl_cthd_exit(rc);
743 return xwosdl_cthd_shld_frz();
769 return xwosdl_cthd_shld_stop();
807 return xwosdl_cthd_frz_shld_stop(frozen);
829 return xwosdl_cthd_sleep_to(
xwtm_ft(dur));
852 return xwosdl_cthd_sleep_to(to);
881 return xwosdl_cthd_sleep_from(from, dur);
907 return xwosdl_cthd_freeze();
910#if (XWOS_THD_LOCAL_DATA_NUM > 0U)
926 return xwosdl_thd_set_data(&thdd.
thd->
osthd, thdd.
tik, pos, data);
944 return xwosdl_thd_get_data(&thdd.
thd->
osthd, thdd.
tik, pos, databuf);
961 return xwosdl_cthd_set_data(pos, data);
978 return xwosdl_cthd_get_data(pos, databuf);
#define __xwos_inline_api
xws64_t xwtm_t
XWOS系统时间 (有符号)
static xwer_t xwos_cthd_sleep_to(xwtm_t to)
XWOS API:线程睡眠到一个时间点
static xwer_t xwos_thd_grab(xwos_thd_d thdd)
XWOS API:增加线程对象的引用计数
static xwer_t xwos_thd_release(xwos_thd_d thdd)
XWOS API:检查对象的标签并减少引用计数
static xwer_t xwos_cthd_get_data(xwsq_t pos, void **databuf)
XWOS API:获取当前线程的本地数据指针
static xwer_t xwos_thd_stop(xwos_thd_d thdd, xwer_t *trc)
XWOS API:终止线程并等待它退出,回收线程内存资源,并抛出线程的返回值
static bool xwos_cthd_shld_stop(void)
XWOS API:判断当前线程是否可以退出
static xwer_t xwos_thd_intr(xwos_thd_d thdd)
XWOS API:中断线程的阻塞态和睡眠态
static void xwos_cthd_get_stack_info(struct xwos_thd_stack_info *stack)
XWOS API:获取线程自身的栈信息
static void xwos_thd_attr_init(struct xwos_thd_attr *attr)
XWOS API:初始化线程属性结构体
static xwer_t xwos_thd_put(xwos_thd_d thdd)
XWOS API:减少线程对象的引用计数
static xwer_t xwos_cthd_sleep_from(xwtm_t *from, xwtm_t dur)
XWOS API:线程从一个时间起点睡眠到另一个时间点
static xwer_t xwos_thd_acquire(xwos_thd_d thdd)
XWOS API:检查线程对象的标签并增加引用计数
static xwer_t xwos_thd_set_data(xwos_thd_d thdd, xwsq_t pos, void *data)
XWOS API:设置线程的本地数据指针
static xwer_t xwos_cthd_freeze(void)
XWOS API:冻结当前线程
static xwer_t xwos_thd_get_stack_usage(xwos_thd_d thdd, xwsz_t *usage)
XWOS API:获取线程的栈用量信息
xwer_t(* xwos_thd_f)(void *)
XWOS API:线程函数指针类型
static xwer_t xwos_thd_get_stack_info(xwos_thd_d thdd, struct xwos_thd_stack_info *stack)
XWOS API:获取线程的栈信息
static bool xwos_cthd_shld_frz(void)
XWOS API:判断当前线程是否可被冻结
static xwer_t xwos_thd_create(xwos_thd_d *thdd, const struct xwos_thd_attr *attr, xwos_thd_f thdfunc, void *arg)
XWOS API:使用动态申请内存方式创建线程并初始化
static void xwos_cthd_get_attr(struct xwos_thd_attr *attr)
XWOS API:获取线程自身的属性
static xwer_t xwos_thd_detach(xwos_thd_d thdd)
XWMP API:分离线程
static xwer_t xwos_thd_quit(xwos_thd_d thdd)
XWOS API:通知线程退出
static xwos_thd_d xwos_cthd_self(void)
XWOS API:获取当前线程的对象描述符
static void xwos_cthd_yield(void)
XWOS API:当前线程通知调度器重新调度
static void xwos_cthd_exit(xwer_t rc)
XWOS API:退出当前线程
static bool xwos_cthd_frz_shld_stop(bool *frozen)
XWOS API:判断当前线程是否可被冻结,如果是,就冻结线程, 之后再判断线程是否可以退出
static xwer_t xwos_thd_migrate(xwos_thd_d thdd, xwid_t dstcpu)
XWOS API:将线程迁移到目标CPU
static xwer_t xwos_cthd_sleep(xwtm_t dur)
XWOS API:当前线程睡眠一段时间
static xwer_t xwos_thd_get_attr(xwos_thd_d thdd, struct xwos_thd_attr *attr)
XWOS API:获取线程的属性
static xwer_t xwos_thd_init(struct xwos_thd *thd, xwos_thd_d *thdd, const struct xwos_thd_attr *attr, xwos_thd_f thdfunc, void *arg)
XWOS API:静态方式初始化线程
static xwer_t xwos_cthd_set_data(xwsq_t pos, void *data)
XWOS API:设置当前线程的本地数据指针
static xwer_t xwos_thd_join(xwos_thd_d thdd, xwer_t *trc)
XWOS API:等待线程结束,回收线程内存资源,抛出它的返回值
static xwer_t xwos_thd_launch(xwos_thd_d thdd, xwos_thd_f thdfunc, void *arg)
XWOS API:加载线程
static xwer_t xwos_thd_get_data(xwos_thd_d thdd, xwsq_t pos, void **databuf)
XWOS API:获取线程的本地数据指针
static xwsz_t xwos_cthd_get_stack_usage(void)
XWOS API:获取线程自身的栈用量信息
static xwtm_t xwtm_ft(xwtm_t dur)
XWOS API:获取当前CPU的未来 系统时间 点
struct xwos_thd_attr attr