用户态支持调节优先级

This commit is contained in:
zhangzheng
2023-09-09 14:48:26 +08:00
parent 74ae8c7a49
commit a94d14da6b
9 changed files with 27 additions and 17 deletions

View File

@@ -0,0 +1,14 @@
/**
* @file futex_backend.c
* @author zhangzheng (1358745329@qq.com)
* @brief 该文件用ipc模拟一个futex锁
* @version 0.1
* @date 2023-09-09
*
* @copyright Copyright (c) 2023
*
*/
void futex_init(void)
{
}

View File

@@ -5,5 +5,5 @@
msg_tag_t thread_msg_buf_set(obj_handler_t obj, void *msg);
msg_tag_t thread_msg_buf_get(obj_handler_t obj, umword_t *msg, umword_t *len);
msg_tag_t thread_exec_regs(obj_handler_t obj, umword_t pc, umword_t sp, umword_t ram);
msg_tag_t thread_run(obj_handler_t obj);
msg_tag_t thread_run(obj_handler_t obj, uint8_t prio);
msg_tag_t thread_bind_task(obj_handler_t obj, obj_handler_t tk_obj);

View File

@@ -62,12 +62,12 @@ msg_tag_t thread_exec_regs(obj_handler_t obj, umword_t pc, umword_t sp, umword_t
return tag;
}
msg_tag_t thread_run(obj_handler_t obj)
msg_tag_t thread_run(obj_handler_t obj, uint8_t prio)
{
register volatile umword_t r0 asm("r0");
syscall(syscall_prot_create(RUN_THREAD, THREAD_PROT, obj),
0,
prio,
0,
0,
0,

View File

@@ -23,14 +23,9 @@ int main(int argc, char *args[])
thread_exit_test();
ipc_test();
map_test();
ipc_timeout_test();
#endif
// ipc_timeout_test();
app_test();
// while (1)
// ;
// factory_create_ipc(FACTORY_PROT, vpage_create_raw3(0, 0, 10));
// factory_create_thread(FACTORY_PROT, vpage_create_raw3(0, 0, 11));
// factory_create_task(FACTORY_PROT, vpage_create_raw3(0, 0, 12));
task_unmap(TASK_THIS, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, TASK_THIS)); // 删除当前task以及申请得所有对象
printf("exit init.\n");
return 0;

View File

@@ -57,7 +57,7 @@ void app_test(void)
tag = thread_msg_buf_set(hd_thread, ram_base + app->i.ram_size);
assert(msg_tag_get_prot(tag) >= 0);
ipc_bind(hd_ipc, hd_thread, 0);
tag = thread_run(hd_thread);
tag = thread_run(hd_thread, 2);
assert(msg_tag_get_prot(tag) >= 0);
char *buf;

View File

@@ -146,7 +146,7 @@ void ipc_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th1_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th1_hd);
tag = thread_run(th1_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
tag = factory_create_thread(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, th2_hd));
@@ -157,7 +157,7 @@ void ipc_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th2_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th2_hd);
tag = thread_run(th2_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
assert(msg_tag_get_prot(tag) >= 0);
@@ -169,7 +169,7 @@ void ipc_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th3_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th3_hd);
tag = thread_run(th3_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
}

View File

@@ -86,7 +86,7 @@ void map_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th1_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th1_hd);
tag = thread_run(th1_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
tag = factory_create_thread(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, th2_hd));
@@ -97,6 +97,6 @@ void map_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th2_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th2_hd);
tag = thread_run(th2_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
}

View File

@@ -67,7 +67,7 @@ void thread_exit_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th1_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th1_hd);
tag = thread_run(th1_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
tag = factory_create_thread(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, th2_hd));
@@ -78,6 +78,6 @@ void thread_exit_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_bind_task(th2_hd, TASK_THIS);
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th2_hd);
tag = thread_run(th2_hd, 2);
assert(msg_tag_get_prot(tag) >= 0);
}