This commit is contained in:
2025-05-16 15:49:50 +03:00
parent 2e372ae9c4
commit 44d09ab13f
2 changed files with 11 additions and 7 deletions
+1
View File
@@ -41,6 +41,7 @@ switchProcess:
mov eax, [esi + 20] ; PCB.RING находится по смещению 20
cmp eax, 3
je .ring3
sti
ret ; Для ring 0 просто возвращаемся
.ring3:
jmp trapret ; Для ring 3 переходим через trapret
+10 -7
View File
@@ -125,21 +125,21 @@ void idle()
while (1) {}
}
void task1(int arg1, char* arg2)
void task1()
{
while (1) {
if (arg1 == 42)
printf("task1 0x%x %s\n", arg1, arg2);
else
printf("ZHOPA %s\n", arg2);
printf("task1\n");
}
}
void task2(int arg1, int arg2)
void task2()
{
while (1) { arg1++; printf("task2 %X %X\n", arg1, arg2); }
int a = 0;
while (1) { a++; printf("task2 %X\n", a); }
}
void jump_usermode2(void) ;
void scheduler_init()
{
task_create((EntryPoint)idle, NULL, 0, 0);
@@ -149,6 +149,7 @@ void scheduler_init()
task_create((EntryPoint)task1, args1, 2, 0);
void* args2[] = {(void*)69, (void*)420};
task_create((EntryPoint)task2, args2, 2, 0);
jump_usermode2();
}
#include "../include/string.h"
@@ -200,6 +201,8 @@ void jump_usermode2(void) {
(uint32_t)user_code_virt, code_pte, code_pte & ~0xFFF,
(code_pte & 0x2) ? "writable" : "read-only",
(code_pte & 0x4) ? "user" : "supervisor");
task_create(user_code_virt, NULL, 0, 3);
// Switch to user mode with interrupts enabled
asm volatile (