Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekrozycki committed Jan 15, 2021
1 parent 63b15cc commit f0dadaa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .idea/BartOS.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,6 @@ clean:
@rm -f $(OBJS)
run-terminal-bochs:
@gnome-terminal -- bochs
run-terminal-qemu:
@gnome-terminal -- qemu-system-i386 os.iso -m 256

Binary file modified os.iso
Binary file not shown.
44 changes: 35 additions & 9 deletions src/Kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,21 @@ _Noreturn int test1(void)
size_t line = 2;
while (1)
{
print_at(TERMINAL, 0,0, "WAITING 1\n");
print_at(TERMINAL, 0,0, "Thread 1 %p\n", current_focus_tcb);
wait_semaphore(t1->kbp_queue->sync);
KBP *packet = key_queue_pop();

if(packet->key_code == KEY_RELEASED_f2)
{
print_at(TERMINAL,0,1, "TEST 1 %p\n", current_focus_tcb);
lock_scheduler();
{
current_focus_tcb = t2;
}
unlock_scheduler();
mili_sleep(500);
print_at(TERMINAL,0,1, "TEST 1 changed %p\n", current_focus_tcb);
}

print_at(TERMINAL,0,line++, "%c %b\n", packet->unicode_code, *packet->status);
if (IS_WRITTABLE(packet->unicode_code))
print_at(TERMINAL,0,line < 24 ? line++ : line, "%c %b\n", packet->unicode_code, *packet->status);

free(packet);
}
Expand All @@ -48,26 +46,52 @@ _Noreturn int test2(void)
size_t line = 2;
while (1)
{
print_at(TERMINAL, 40,0, "WAITING 2 %p\n", current_focus_tcb);
print_at(TERMINAL, 40,0, "Thread 2 %p\n", current_focus_tcb);
wait_semaphore(t2->kbp_queue->sync);
KBP *packet = key_queue_pop();

if(packet->key_code == KEY_RELEASED_f1)
{
print_at(TERMINAL,40,1, "TEST 2\n");
lock_scheduler();
{
current_focus_tcb = t1;
}
unlock_scheduler();
}

print_at(TERMINAL,40,line++, "%c %b\n", packet->unicode_code, *packet->status);
if (IS_WRITTABLE(packet->unicode_code))
print_at(TERMINAL,40,line < 24 ? line++ : line, "%c %b\n", packet->unicode_code, *packet->status);

free(packet);
}
}

_Noreturn int test3(void)
{
int time = 0;
while (1)
{
print_at(TERMINAL, 30, 0, "TIMER %d", ++time);
sleep(1);
if (time % 5 == 0)
{
terminal_setcolor(TERMINAL_COLOR_BLUE_SCREEN_OF_DEATH);
}
if (time % 10 == 0)
{
terminal_setcolor(TERMINAL_COLOR_DOS_DEFAULT);
}
}
}
_Noreturn int test4(void)
{
int time = 0;
sleep(3);
while (1)
{
print_at(TERMINAL, 20, 0, "TIMER %d", ++time);
sleep(1);
}
}
_Noreturn void Main(MultibootInfo *mbi) // DO NOT USE MBI BECAUSE IT IS NOT MAPPED:)
{
init_gdt();
Expand All @@ -85,6 +109,8 @@ _Noreturn void Main(MultibootInfo *mbi) // DO NOT USE MBI BECAUSE IT IS NOT MAPP

test = create_mutex();

thread_create(test3);
thread_create(test4);
t2 = thread_create(test2);
t1 = thread_create(test1);

Expand Down

0 comments on commit f0dadaa

Please sign in to comment.