os_schedule_request

所属模块:调度系统 | 类型:调度触发函数

API Metadata

函数ID:os_schedule_request
模块:scheduler
类型:schedule trigger
嵌套深度:1

函数简介

os_schedule_request 用于请求系统重新调度任务, 通过强制触发Timer0中断,使系统在中断上下文中执行调度逻辑。

该方式避免直接调用调度器,提高系统安全性与一致性。

函数原型

char os_schedule_request(char id);

参数说明

参数 说明
id 保留参数(当前未使用,用于后续扩展)

返回值

1 - 成功触发调度

源码实现

#include"hrtos_internal.h" /* * 请求系统重新调度 * * 功能: * 强制使Timer0快速溢出, * 从而提前触发一次系统tick中断, * 使系统在中断中执行任务调度。 * * 说明: * 本函数不直接调用调度器, * 而是通过触发系统时钟中断实现安全调度。 */ char os_schedule_request(char id) { id = id; /* 保留参数,便于后续扩展 */ OS_SCHED_REASON = 1; /* 设置调度触发位 */ TF0 = 1; /* 触发Timer0中断 */ return 1; }

使用示例

void task_yield() { os_schedule_request(0); }

注意事项

该函数不会直接调用调度器,而是通过中断机制触发调度, 必须确保Timer0中断已正确配置。

相关推荐