!8 修复thread删除时,导致assert的bug

Merge pull request !8 from 张正/feature-mul-core
This commit is contained in:
张正
2023-11-26 09:01:40 +00:00
committed by Gitee
12 changed files with 61 additions and 59 deletions

View File

@@ -95,7 +95,9 @@ static void thread_release_stage1(kobject_t *kobj)
{
thread_suspend(th);
}
}else {
}
else
{
if (cur->status == THREAD_READY)
{
thread_suspend(th);
@@ -125,7 +127,10 @@ static void thread_release_stage1(kobject_t *kobj)
slist_del(&pos->wait_node);
pos = next;
}
slist_del(&th->wait_node); //!< 从链表中删除
if (slist_in_list(&th->wait_node))
{
slist_del(&th->wait_node); //!< 从链表中删除
}
thread_unbind(th);
}
static void thread_release_stage2(kobject_t *kobj)
@@ -724,6 +729,11 @@ static void thread_syscall(kobject_t *kobj, syscall_prot_t sys_p, msg_tag_t in_t
break;
case RUN_THREAD:
{
if (thread_get_bind_task(tag_th) == NULL)
{
tag = msg_tag_init4(0, 0, 0, -EACCES);
break;
}
umword_t status = cpulock_lock();
if (!slist_in_list(&tag_th->sche.node))
{

View File

@@ -84,7 +84,7 @@ typedef union vpage
};
} vpage_t;
#define VPAGE_FLAGS_MAP 0x1 //!< 是否ipc时立刻映射
#define VPAGE_FLAGS_MAP 0x1 //!< 是否ipc时立刻映射, 可以在ipc通信时忽略进行ipc这样不会报错
static inline vpage_t vpage_create_raw(umword_t raw)
{

View File

@@ -1,5 +1,5 @@
#define HEAP_SIZE 512
#define HEAP_SIZE 8192
#define STACK_SIZE 1024 * 2
#if defined(__CC_ARM)

View File

@@ -22,43 +22,43 @@ extern void futex_init(void);
int main(int argc, char *args[])
{
ulog_write_str(LOG_PROT, "init..\n");
#if 0
ulog_test();
factory_test();
printf_test();
thread_test();
thread_exit_test();
map_test();
mm_test();
app_test();
mpu_test();
thread_press_test();
kobj_create_press_test();
pthread_cond_lock_test();
pthread_lock_test();
u_sleep_ms(1000);
ipc_test();
ipc_obj_test();
#if 1
// ulog_test();
// factory_test();
// printf_test();
// thread_exit_test();
// map_test();
// mm_test();
// app_test();
// mpu_test();
// thread_press_test();
// kobj_create_press_test();
// pthread_cond_lock_test();
// pthread_lock_test();
// u_sleep_ms(1000);
// ipc_test();
// ipc_obj_test();
#endif
uenv_t env = *u_get_global_env();
env.ns_hd = namespace_init();
int ret;
ret = ret;
// ret = app_load("mr_drv", &env);
// if (ret < 0)
// {
// printf("%s load fail, 0x%x\n", "mr_drv", ret);
// }
ret = app_load("rtthread_drv", &env);
ret = app_load("mr_drv", &env);
if (ret < 0)
{
printf("%s load fail, 0x%x\n", "mr_drv", ret);
}
// ret = app_load("hello", &env);
// ret = app_load("rtthread_drv", &env);
// if (ret < 0)
// {
// printf("%s load fail, 0x%x\n", "hello", ret);
// printf("%s load fail, 0x%x\n", "mr_drv", ret);
// }
ret = app_load("hello", &env);
if (ret < 0)
{
printf("%s load fail, 0x%x\n", "hello", ret);
}
// ret = app_load("app", &env);
// if (ret < 0)
// {

View File

@@ -10,10 +10,6 @@ void factory_test(void)
obj_handler_t hd = handler_alloc();
assert(hd != HANDLER_INVALID);
msg_tag_t tag = factory_create_ipc(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, hd));
if (msg_tag_get_prot(tag) < 0)
{
printf("factory_create_ipc no memory\n");
return;
}
assert(msg_tag_get_prot(tag) >= 0);
handler_free_umap(hd);
}

View File

@@ -12,9 +12,12 @@
#include "test.h"
void kobj_create_press_test(void)
{
while (1)
int i = 1000;
while (i--)
{
msg_tag_t tag = factory_create_ipc(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, handler_alloc()));
obj_handler_t hd = handler_alloc();
msg_tag_t tag = factory_create_ipc(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, hd));
assert(msg_tag_get_prot(tag) >= 0);
handler_free_umap(hd);
}
}

View File

@@ -6,7 +6,7 @@ void ulog_test(void)
{
uint8_t data[10];
ulog_write_str(LOG_PROT, "Init task running..\n");
ulog_write_str(LOG_PROT, "Please key..\n");
int len = ulog_read_bytes(LOG_PROT, data, sizeof(data) - 1);
if (len > 0)

View File

@@ -44,6 +44,7 @@ static void thread_test_func(void)
thread_ipc_reply(msg_tag_init4(0, ROUND_UP(strlen(buf), WORD_BYTES), 0, 0), ipc_timeout_create2(0, 0));
printf("thread_test_func.\n");
handler_free(log_hd);
handler_free(th1_hd);
task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th1_hd));
printf("Error\n");
}
@@ -56,10 +57,11 @@ static void thread_test_func2(void)
thread_msg_buf_get(th2_hd, (umword_t *)(&buf), NULL);
ipc_msg = (ipc_msg_t *)buf;
strcpy((char *)(ipc_msg->msg_buf), "I am th2.\n");
ipc_msg->map_buf[0] = vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, LOG_PROT).raw;
ipc_msg->map_buf[0] = vpage_create_raw3(KOBJ_DELETE_RIGHT, VPAGE_FLAGS_MAP, LOG_PROT).raw;
thread_ipc_call(msg_tag_init4(0, ROUND_UP(strlen((char *)(ipc_msg->msg_buf)), WORD_BYTES), 1, 0), th1_hd, ipc_timeout_create2(0, 0));
printf("th2:%s", buf);
printf("thread_test_func2.\n");
handler_free(th1_hd);
task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th2_hd));
printf("Error\n");
}

View File

@@ -8,7 +8,7 @@ void printf_test(void)
float a = 1.1;
float b = 1.2;
float c = a + b;
// printf("%c %d %f\n", 'a', 1234, 1.1);
// c = c;
// printf("%c %d %lf\n", 'a', 1234, 1.1); 浮点打印有问题
}
printf("%c %d %f\n", 'a', 1234, 1.1);
c = c;
printf("%c %d %lf\n", 'a', 1234, 1.1);
}

View File

@@ -4,7 +4,6 @@
void mm_test(void);
void ulog_test(void);
void factory_test(void);
void thread_test(void);
void app_test(void);
void mpu_test(void);
void printf_test(void);

View File

@@ -31,7 +31,8 @@ static void thread_test_func(void)
umword_t len;
thread_msg_buf_get(th1_hd, (umword_t *)(&buf), NULL);
printf("thread_test_func.\n");
task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th1_hd));
// task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th1_hd));
handler_free_umap(th1_hd);
printf("Error\n");
}
static void thread_test_func2(void)
@@ -40,7 +41,8 @@ static void thread_test_func2(void)
umword_t len;
thread_msg_buf_get(th2_hd, (umword_t *)(&buf), NULL);
printf("thread_test_func2.\n");
task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th2_hd));
// task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th2_hd));
handler_free_umap(th2_hd);
printf("Error\n");
}

View File

@@ -9,22 +9,16 @@
#include <assert.h>
#include <stdio.h>
#include "test.h"
#include "u_sleep.h"
static umword_t th1_hd = 0;
static umword_t ipc_hd = 0;
static int i = 100;
#define STACK_SIZE 512
#define STACK_SIZE 1024
static __attribute__((aligned(8))) uint8_t stack0[STACK_SIZE];
static void thread_test_func(void)
{
// char *buf;
// umword_t len;
// thread_msg_buf_get(th1_hd, (umword_t *)(&buf), NULL);
// printf("thread_test_func.\n");
ulog_write_str(LOG_PROT, ".");
// task_unmap(TASK_PROT, vpage_create_raw3(KOBJ_DELETE_RIGHT, 0, th1_hd));
handler_free_umap(ipc_hd);
handler_free_umap(th1_hd);
printf("Error\n");
}
@@ -35,11 +29,8 @@ void thread_press_test(void)
{
th1_hd = handler_alloc();
assert(th1_hd != HANDLER_INVALID);
ipc_hd = handler_alloc();
assert(ipc_hd != HANDLER_INVALID);
msg_tag_t tag;
msg_tag_t tag = factory_create_ipc(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, ipc_hd));
assert(msg_tag_get_prot(tag) >= 0);
tag = factory_create_thread(FACTORY_PROT, vpage_create_raw3(KOBJ_ALL_RIGHTS, 0, th1_hd));
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_exec_regs(th1_hd, (umword_t)thread_test_func, (umword_t)stack0 + STACK_SIZE, RAM_BASE(), 0);
@@ -48,7 +39,6 @@ void thread_press_test(void)
assert(msg_tag_get_prot(tag) >= 0);
tag = thread_run(th1_hd, 2);
ulog_write_str(LOG_PROT, "\n");
// sleep_tick(20);
u_sleep_ms(10);
}
}