Move sleep Thread to test

This commit is contained in:
Mathieu Maret 2020-07-06 17:21:49 +02:00
parent 88d0266d76
commit 5de1c54b61
2 changed files with 15 additions and 15 deletions

View File

@ -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 :
// 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
@ -127,7 +117,6 @@ void kmain(unsigned long magic, unsigned long addr)
allocSetup();
kthreadSetup(_stack_bottom, (_stack_top - _stack_bottom + 1));
kthreadCreate("idle ", idleThread, NULL);
kthreadCreate("sleep", sleepThread, NULL);
irqSetRoutine(IRQ_TIMER, pit_handler);
#ifdef RUN_TEST
run_test();

View File

@ -218,9 +218,8 @@ void testCoroutine()
static void kthread1(void *strIn)
{
char *str = (char *)strIn;
printf("\nkth1: %s\n", (char *)strIn);
for (; *str != '\n'; str++) {
printf("kth1_: %c\n", *str);
printf("kth1: %c\n", *str);
kthreadYield();
}
}
@ -228,17 +227,29 @@ static void kthread1(void *strIn)
static void kthread2(void *strIn)
{
char *str = (char *)strIn;
printf("\nkth2: %s\n", (char *)strIn);
for (; *str != '\n'; str++) {
printf("kth2_: %c\n", *str);
printf("kth2: %c\n", *str);
kthreadYield();
}
}
void sleepThread(void *arg){
(void)arg;
int secSleep = 0;
while (1){
printf("Sleeping loop %d\n", secSleep);
secSleep++;
kthreadMsleep(1000);
}
}
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("Test2", (cpu_kstate_function_arg1_t *)kthread2, (void *)"el ol\n");
kthreadMsleep(1000);
kthreadCreate("sleep", sleepThread, NULL);
}
void run_test(void)