raphydaphy / Q-Operating-System

Q OS is a versatile operating system designed with the new features of 64 bit "long mode" CPU's in mind that focuses on making everything as simple as possible for the end user
http://q-os.tech
GNU Lesser General Public License v3.0
149 stars 41 forks source link

Adding Multitasking! #39

Open plankp opened 8 years ago

plankp commented 8 years ago

I am having trouble figuring this one out... Maybe a Unix fork execve like style or a brand new one be implemented?

raphydaphy commented 8 years ago

Nuuuuu not unix stuff ): Q is meant to be from scratch :+1:

But shouldn't we make the current things work better before thinking about multitasking because multitasking is pretty hard :disappointed:

Barteks2x commented 8 years ago

I was actually able to get simple scheduler working (but I only tested it with one task/thread/process). And I can't load executab;e files so I don't think it really counts as multitasking.

plankp commented 8 years ago

good enough

raphydaphy commented 8 years ago

ok den

sounds cool

Barteks2x commented 8 years ago

I will try to make "writer" and "cat" separate processes (so that I'm sure it works).

plankp commented 8 years ago

:+1:

raphydaphy commented 8 years ago

:+1:

Barteks2x commented 8 years ago

Somehow I stop getting interrupts when I add second thread/task/process.

Barteks2x commented 8 years ago

I partially got it working with multiple kernel tasks. Trying to figure out why it sets stack pointer to wrong but accidentally "correct" value. Is there some way to actually debug it other than adding a bunch of prints?

raphydaphy commented 8 years ago

You can debug the booting process using Debug Mode in the OS selection on grub, but idk about after you have booted the OS..

plankp commented 8 years ago

Moving it to ready

plankp commented 8 years ago

Anyone know what's going on with this multitasking?

raphydaphy commented 8 years ago

Did Barteks2x quit?

plankp commented 8 years ago

I don't think so?

Barteks2x commented 8 years ago

For last few days I didn't have enough free time. I will try to do something this weekend. I have a few problems with multitasking. I need to do some changes to isr and irq handlers. I want to save thread state on it's stack. And I actually need to create separate stack for it. And I have weird issue (probably caused by not using separate stack, but when I try setting different stack - it magically resets itself to what it was before). I have this function: https://github.com/Barteks2x/Q-OS/blob/8888ddc936f7152c204d72f20641cdd8e5b8ef6a/kernel/inc/thread.c#L86 And without the int i = 0 it doesn't work (a lot of illegal opcodes). When I replace it with nop (__asm__ __volatile__("nop")) I get page faults instead.

plankp commented 8 years ago

Maybe NOP a couple times instead of int i = 0?

Barteks2x commented 8 years ago

*edited my comment - added what if I use nop.

Barteks2x commented 8 years ago

What is even more weird - if I move that int i = 0; before the loop - it still works. But it I remove it - it breaks.

Barteks2x commented 8 years ago

I tried adding a few NOPs - the same as with only one.

raphydaphy commented 8 years ago

gl :+1:

Your code looks pretty good so far

plankp commented 8 years ago

Maybe push some value?

plankp commented 8 years ago

What if you don't hlt and just loop?

Barteks2x commented 8 years ago

Bad things happen (but that's because for some reason I can't force it to use different stack yet).

plankp commented 8 years ago

oh. ok