new: 增加ktest_start函数以开启内核自测试

This commit is contained in:
fslongjin 2022-07-29 17:40:55 +08:00
parent c1f51bf4cb
commit 7c9366b297
6 changed files with 33 additions and 5 deletions

View File

@ -2,7 +2,10 @@
CFLAGS += -I . CFLAGS += -I .
all: bitree.o kfifo.o all: ktest.o bitree.o kfifo.o
ktest.o: ktest.c
gcc $(CFLAGS) -c ktest.c -o ktest.o
bitree.o: test-bitree.c bitree.o: test-bitree.c
gcc $(CFLAGS) -c test-bitree.c -o test-bitree.o gcc $(CFLAGS) -c test-bitree.c -o test-bitree.o

14
kernel/ktest/ktest.c Normal file
View File

@ -0,0 +1,14 @@
#include "ktest.h"
#include <process/process.h>
/**
* @brief 线
*
* @param func
* @param arg
* @return pid_t 线pid
*/
pid_t ktest_start(uint64_t (*func)(uint64_t arg), uint64_t arg)
{
return kernel_thread(func, arg, 0);
}

View File

@ -2,4 +2,13 @@
#include <common/sys/types.h> #include <common/sys/types.h>
uint64_t ktest_test_bitree(uint64_t arg); uint64_t ktest_test_bitree(uint64_t arg);
uint64_t ktest_test_kfifo(uint64_t arg); uint64_t ktest_test_kfifo(uint64_t arg);
/**
* @brief 线
*
* @param func
* @param arg
* @return pid_t 线pid
*/
pid_t ktest_start(uint64_t (*func)(uint64_t arg), uint64_t arg);

View File

@ -541,11 +541,13 @@ void *kmalloc(unsigned long size, unsigned long flags)
} }
int index; int index;
for (int i = 0; i < 16; ++i) for (int i = 0; i < 16; ++i)
{
if (kmalloc_cache_group[i].size >= size) if (kmalloc_cache_group[i].size >= size)
{ {
index = i; index = i;
break; break;
} }
}
struct slab_obj *slab_obj_ptr = kmalloc_cache_group[index].cache_pool_entry; struct slab_obj *slab_obj_ptr = kmalloc_cache_group[index].cache_pool_entry;

View File

@ -416,8 +416,8 @@ ul initial_kernel_thread(ul arg)
usb_init(); usb_init();
// 对一些组件进行单元测试 // 对一些组件进行单元测试
kernel_thread(ktest_test_bitree, 0, 0); ktest_start(ktest_test_bitree, 0);
kernel_thread(ktest_test_kfifo, 0, 0); ktest_start(ktest_test_kfifo, 0);
// 准备切换到用户态 // 准备切换到用户态
struct pt_regs *regs; struct pt_regs *regs;

View File

@ -115,7 +115,7 @@ struct process_control_block
// 进程切换时保存的状态信息 // 进程切换时保存的状态信息
struct thread_struct *thread; struct thread_struct *thread;
// 连接各个pcb的双向链表todo删除这个变量 // 连接各个pcb的双向链表
struct List list; struct List list;
// 地址空间范围 // 地址空间范围