Q-Operating-System icon indicating copy to clipboard operation
Q-Operating-System copied to clipboard

Adding Multitasking!

Open plankp opened this issue 9 years ago • 24 comments

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

plankp avatar Nov 19 '15 02:11 plankp

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:

raphydaphy avatar Nov 19 '15 04:11 raphydaphy

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.

Barteks2x avatar Nov 20 '15 02:11 Barteks2x

good enough

plankp avatar Nov 20 '15 02:11 plankp

ok den

sounds cool

raphydaphy avatar Nov 20 '15 02:11 raphydaphy

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

Barteks2x avatar Nov 20 '15 03:11 Barteks2x

:+1:

plankp avatar Nov 20 '15 03:11 plankp

:+1:

raphydaphy avatar Nov 20 '15 03:11 raphydaphy

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

Barteks2x avatar Nov 20 '15 04:11 Barteks2x

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?

Barteks2x avatar Nov 21 '15 02:11 Barteks2x

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

raphydaphy avatar Nov 21 '15 02:11 raphydaphy

Moving it to ready

plankp avatar Nov 21 '15 18:11 plankp

Anyone know what's going on with this multitasking?

plankp avatar Nov 24 '15 21:11 plankp

Did Barteks2x quit?

raphydaphy avatar Nov 24 '15 21:11 raphydaphy

I don't think so?

plankp avatar Nov 24 '15 21:11 plankp

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.

Barteks2x avatar Nov 25 '15 02:11 Barteks2x

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

plankp avatar Nov 25 '15 02:11 plankp

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

Barteks2x avatar Nov 25 '15 02:11 Barteks2x

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 avatar Nov 25 '15 02:11 Barteks2x

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

Barteks2x avatar Nov 25 '15 02:11 Barteks2x

gl :+1:

Your code looks pretty good so far

raphydaphy avatar Nov 25 '15 02:11 raphydaphy

Maybe push some value?

plankp avatar Nov 25 '15 02:11 plankp

What if you don't hlt and just loop?

plankp avatar Nov 25 '15 03:11 plankp

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

Barteks2x avatar Nov 25 '15 03:11 Barteks2x

oh. ok

plankp avatar Nov 25 '15 03:11 plankp