Move sleep Thread to test
This commit is contained in:
parent
88d0266d76
commit
5de1c54b61
11
core/main.c
11
core/main.c
@ -32,16 +32,6 @@ void idleThread(void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleepThread(void *arg){
|
|
||||||
(void)arg;
|
|
||||||
int secSleep = 0;
|
|
||||||
while (1){
|
|
||||||
printf("Sleeping loop %d\n", secSleep);
|
|
||||||
secSleep++;
|
|
||||||
kthreadMsleep(1000);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Multiboot information available here :
|
// Multiboot information available here :
|
||||||
// https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#kernel_002ec
|
// https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#kernel_002ec
|
||||||
// https://www.gnu.org/software/grub/manual/multiboot/html_node/Boot-information-format.html#Boot%20information%20format
|
// https://www.gnu.org/software/grub/manual/multiboot/html_node/Boot-information-format.html#Boot%20information%20format
|
||||||
@ -127,7 +117,6 @@ void kmain(unsigned long magic, unsigned long addr)
|
|||||||
allocSetup();
|
allocSetup();
|
||||||
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
|
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
|
||||||
kthreadCreate("idle ", idleThread, NULL);
|
kthreadCreate("idle ", idleThread, NULL);
|
||||||
kthreadCreate("sleep", sleepThread, NULL);
|
|
||||||
irqSetRoutine(IRQ_TIMER, pit_handler);
|
irqSetRoutine(IRQ_TIMER, pit_handler);
|
||||||
#ifdef RUN_TEST
|
#ifdef RUN_TEST
|
||||||
run_test();
|
run_test();
|
||||||
|
19
tests/test.c
19
tests/test.c
@ -218,9 +218,8 @@ void testCoroutine()
|
|||||||
static void kthread1(void *strIn)
|
static void kthread1(void *strIn)
|
||||||
{
|
{
|
||||||
char *str = (char *)strIn;
|
char *str = (char *)strIn;
|
||||||
printf("\nkth1: %s\n", (char *)strIn);
|
|
||||||
for (; *str != '\n'; str++) {
|
for (; *str != '\n'; str++) {
|
||||||
printf("kth1_: %c\n", *str);
|
printf("kth1: %c\n", *str);
|
||||||
kthreadYield();
|
kthreadYield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -228,17 +227,29 @@ static void kthread1(void *strIn)
|
|||||||
static void kthread2(void *strIn)
|
static void kthread2(void *strIn)
|
||||||
{
|
{
|
||||||
char *str = (char *)strIn;
|
char *str = (char *)strIn;
|
||||||
printf("\nkth2: %s\n", (char *)strIn);
|
|
||||||
for (; *str != '\n'; str++) {
|
for (; *str != '\n'; str++) {
|
||||||
printf("kth2_: %c\n", *str);
|
printf("kth2: %c\n", *str);
|
||||||
kthreadYield();
|
kthreadYield();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sleepThread(void *arg){
|
||||||
|
(void)arg;
|
||||||
|
int secSleep = 0;
|
||||||
|
while (1){
|
||||||
|
printf("Sleeping loop %d\n", secSleep);
|
||||||
|
secSleep++;
|
||||||
|
kthreadMsleep(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void testKthread()
|
void testKthread()
|
||||||
{
|
{
|
||||||
|
// It is not expected to have necessarily "Hello world\n" properly written
|
||||||
kthreadCreate("Test1", (cpu_kstate_function_arg1_t *)kthread1, (void *)"Hlowrd\n");
|
kthreadCreate("Test1", (cpu_kstate_function_arg1_t *)kthread1, (void *)"Hlowrd\n");
|
||||||
kthreadCreate("Test2", (cpu_kstate_function_arg1_t *)kthread2, (void *)"el ol\n");
|
kthreadCreate("Test2", (cpu_kstate_function_arg1_t *)kthread2, (void *)"el ol\n");
|
||||||
|
kthreadMsleep(1000);
|
||||||
|
kthreadCreate("sleep", sleepThread, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_test(void)
|
void run_test(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user