Multitasking

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Awe2K
Member
Member
Posts: 49
Joined: Sat Oct 24, 2015 3:14 am
Libera.chat IRC: awe2k

Multitasking

Post by Awe2K »

Hello, it's me again and I have been searching the internet for some tutorials on multitasking, but I haven't found, old links on osdev forums are pointing to removed pages.
I've tried JamesM, but it's buggy as erm... you know. Also, I've already implemented paging and page allocation (one method allocates from start, and one allocates pages from end for stack (stack grows to bottom, as far as I know)). I've tried to implement multitasking by myself, but it doesn't seem to work normally (only for 2 tasks).

Could you please give me some advice on how to go and from what to start, or give some links on tutorials?
I'd be very glad.

Thanks, Awe2K.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Multitasking

Post by Muazzam »

I found CS401 from VU, Pakistan very helpful. A few lectures are about multitasking that may help. They're in Urdu but the slides are in English.

You can watch lecture #30: www.youtube.com/watch?v=m8SNm3VVOVw.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Multitasking

Post by Muazzam »

I found CS401 from VU, Pakistan very helpful. A few lectures are about multitasking that may help. They're in Urdu but the slides are in English.

You might like to watch lecture 30 to lecture 32: http://www.youtube.com/watch?v=m8SNm3VVOVw.
Awe2K
Member
Member
Posts: 49
Joined: Sat Oct 24, 2015 3:14 am
Libera.chat IRC: awe2k

Re: Multitasking

Post by Awe2K »

Thanks, I'll try it out. Are there other things I have to implement before making multitasking?
Awe2K
Member
Member
Posts: 49
Joined: Sat Oct 24, 2015 3:14 am
Libera.chat IRC: awe2k

Re: Multitasking

Post by Awe2K »

Also, this seems a tutorial for real mode, because it still uses segment:offset addresses. I've already switched to protected mode, so many things may not suit. Instead of seg:off I have paging enabled (just identity-mapped all memory). Now I'm able to allocate pages for stack and heap. In fact, here's screenshot of my kernel working, but as far as I know, it needs some way of executing programs (I can load and jump to ELF, but can't return).
(That white thing is a cursor :))
Attachments
scv.png
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Multitasking

Post by Muazzam »

Awe2K wrote:Thanks, I'll try it out. Are there other things I have to implement before making multitasking?
No. I've even implemented multi-tasking (though poor one) in a bootsector program. Which is, of course, 16-bit.

EDIT: [...]
Last edited by Muazzam on Tue Oct 27, 2015 7:22 am, edited 1 time in total.
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Multitasking

Post by Muazzam »

Awe2K wrote:Also, this seems a tutorial for real mode, because it still uses segment:offset addresses. I've already switched to protected mode, so many things may not suit. Instead of seg:off I have paging enabled (just identity-mapped all memory). Now I'm able to allocate pages for stack and heap. In fact, here's screenshot of my kernel working, but as far as I know, it needs some way of executing programs (I can load and jump to ELF, but can't return).
(That white thing is a cursor :))
Oh. By the way, if you've not ever tried multi-tasking, writing a task-switching program in real mode won't hurt.
Awe2K
Member
Member
Posts: 49
Joined: Sat Oct 24, 2015 3:14 am
Libera.chat IRC: awe2k

Re: Multitasking

Post by Awe2K »

muazzam wrote:Oh. By the way, if you've not ever tried multi-tasking, writing a task-switching program in real mode won't hurt.
Actually, I've tried both in real mode and protected mode. In real mode it was kinda easier, but now I'm in protected mode, and there's no more segments,
I'm using paging which is quite different (segments are non-fixed, whereas pages are 4kbytes).
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Multitasking

Post by Muazzam »

Awe2K wrote: Actually, I've tried both in real mode and protected mode. In real mode it was kinda easier, but now I'm in protected mode, and there's no more segments,
I'm using paging which is quite different (segments are non-fixed, whereas pages are 4kbytes).
I'm sorry. I assumed that you were quite beginner but you are not.
Awe2K
Member
Member
Posts: 49
Joined: Sat Oct 24, 2015 3:14 am
Libera.chat IRC: awe2k

Re: Multitasking

Post by Awe2K »

muazzam wrote:
Awe2K wrote: Actually, I've tried both in real mode and protected mode. In real mode it was kinda easier, but now I'm in protected mode, and there's no more segments,
I'm using paging which is quite different (segments are non-fixed, whereas pages are 4kbytes).
I'm sorry. I assumed that you were quite beginner but you are not.
If it's about multitasking or loading executables, I am. I'm trying to create OS with console terminal, and I need multitasking just to run some daemons/services in background.
But I think I know other things needed to begin developing OS (paging, interrupts, some protected mode stuff).
User avatar
Muazzam
Member
Member
Posts: 543
Joined: Mon Jun 16, 2014 5:59 am
Location: Shahpur, Layyah, Pakistan

Re: Multitasking

Post by Muazzam »

Have you tried http://geezer.osdevbrasil.net/osd/tasks/index.htm? (Caution: I *haven't tried it personally.)

EDIT: I didn't notice. I have four stars now! :D
Last edited by Muazzam on Tue Oct 27, 2015 8:03 am, edited 1 time in total.
Awe2K
Member
Member
Posts: 49
Joined: Sat Oct 24, 2015 3:14 am
Libera.chat IRC: awe2k

Re: Multitasking

Post by Awe2K »

muazzam wrote:Have you tried http://geezer.osdevbrasil.net/osd/tasks/index.htm? (Caution: I've tried it personally.)

EDIT: I didn't notice. I have four stars now! :D
No, I haven't yet, now I'm steps from implementing ELF loader :)
I think, that after I load ELF I should give it virtual address space (page, or something like that) and jump to it.
That way almost worked for me, but the one problem is program doesn't know where to return (after execution my kernel just hangs or throws interrupt about invalid opcode).
After I solve that problem, I think I would be able to start some services from initial ramdisk (loaded by grub2).
Post Reply