Multitasking disables interrupts

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
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Multitasking disables interrupts

Post by Creature »

I have another question and/or problem; is there any way multitasking (or context switching) would disable interrupts (of all kinds)? When I fork() in my OS and the function returns, my OS prints a certain string, after which the PIT switches contexts and the second 'process' prints the same string (as it should). But after both processes have had their timeslice (and the PIT switched once), interrupts just stop working. The PIT isn't called anymore, the keyboard gets disabled and I've made sure that every time I disable interrupts, they are enabled correctly again. I've even tried to let both processes re-enable interrupts, with no result however. I do not get a CPU fault or trap of any kind, execution just plainly continues as it should, but interrupts are disabled.

Any idea's why this would happen? Is it possible that the CPU does not allow interrupts in the newly process originated from the fork()? As this would be strange, as how else am I supposed to change contexts again?

Thanks,
Creature
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Multitasking disables interrupts

Post by xenos »

Just a few suggestions:
  • Are you sure that interrupts are disabled, i.e. have you checked the IF in the EFLAGS register? If just re-enabling interrupts does not change anything, the problem might be in some other place. (Or they are disabled again?)
  • Do all of your interrupt handlers send an end-of-interrupt to the PIC before returning?
  • Are you running on a real box or something like bochs? Using bochs you can create a log file with option debug=report. (Be careful, that can result in a really huge log file!) Then you can check when interrupts are disabled / enabled, the PIC is notified etc.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Multitasking disables interrupts

Post by Creature »

XenOS wrote:Are you sure that interrupts are disabled, i.e. have you checked the IF in the EFLAGS register? If just re-enabling interrupts does not change anything, the problem might be in some other place. (Or they are disabled again?)
I'll check a few times over again soon.
XenOS wrote:Do all of your interrupt handlers send an end-of-interrupt to the PIC before returning?
Yes, every interrupt goes through the same procedure. The interrupts work fine at first, but only work if I fork() a process or actually start using more than 1 process in any way.
XenOS wrote:Are you running on a real box or something like bochs? Using bochs you can create a log file with option debug=report. (Be careful, that can result in a really huge log file!) Then you can check when interrupts are disabled / enabled, the PIC is notified etc.
The Bochs log file is huge, indeed. According to the file, my timer is called perfectly like in the beginning, but for some reason I'm not getting any timer signal nor keyboard input events and such.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
hailstorm
Member
Member
Posts: 110
Joined: Wed Nov 02, 2005 12:00 am
Location: The Netherlands

Re: Multitasking disables interrupts

Post by hailstorm »

I once had the same problem, when I implemented multitasking in my OS. It worked out that, as soon as I switched to the second task, the interrupt handler didn't finish, because the second task wasn't aware of the ISR being executed (since the EIP of the interrupt handler resides on the other task's kernelstack). If this is the case with your kernel, you have to modify your ISR's, so that a end of interrupt is always sent to the PIC.

Hope this helps, good luck!

Greetz.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: Multitasking disables interrupts

Post by Creature »

hailstorm wrote:I once had the same problem, when I implemented multitasking in my OS. It worked out that, as soon as I switched to the second task, the interrupt handler didn't finish, because the second task wasn't aware of the ISR being executed (since the EIP of the interrupt handler resides on the other task's kernelstack). If this is the case with your kernel, you have to modify your ISR's, so that a end of interrupt is always sent to the PIC.

Hope this helps, good luck!

Greetz.
Thank you VERY much, I'm deeply disappointed in myself :P. You gave me some golden advice there, this was indeed what was happening. I let my IRQ handler acknowlede the IRQ AFTER the task switching occurred. This way the switching occurred but the IRQ handler never acknowledged anything. It's fixed now (FINALLY).

Thanks for your time and advice :).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
hailstorm
Member
Member
Posts: 110
Joined: Wed Nov 02, 2005 12:00 am
Location: The Netherlands

Re: Multitasking disables interrupts

Post by hailstorm »

I'm just glad I could help. This problem also gave me a headache and a hard time to solve it. :mrgreen:
Post Reply