2 problems - one thread

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
cmp

2 problems - one thread

Post by cmp »

hi,

i'm new in this forum and i'm a pretty lousy english writer, but i think you'll notice this soon :)

i got two questions, but i dont want to spam the whole forum, so i only make on thread

my first question is: is there any way to determine, wheter an interrupt suspended another interrupt?
eg: i got my timer interrupt switching the tasks, but i'dont want a task to be switch, if a interupt is currently running

the whole thing should take place in the real mode

the second question is: how can i determine the sector size of a disk, must i rely on the first sector (with fat there's a sector size statement, but what's with non fat disks?)?

cu, thanks in advance
eL JeDi

Re:2 problems - one thread

Post by eL JeDi »

Hi cmp,
my first question is: is there any way to determine, wheter an interrupt suspended another interrupt?
eg: i got my timer interrupt switching the tasks, but i'dont want a task to be switch, if a interupt is currently running
I think i didn't understand you well, but when you enter on an interrupt its a good idea to disable ints ( cli ) and when you exit from it enable all interrupts ( sti ). So you can put cli at the beginning of your ISR and sti at the end.

If you are talking about IRQ, ( in ex the timer ) when you enter on it, interrupts are disable until you send 0x20 to 0x20 port that indicates end of interrupts.
( i am not sure about that, can anyone confirm it? )

the second question is: how can i determine the sector size of a disk, must i rely on the first sector (with fat there's a sector size statement, but what's with non fat disks?)?
If you are talking about fisical sector, they are 512ks. Logical sectors you choose the size.
jrfritz

Re:2 problems - one thread

Post by jrfritz »

eL JeDi wrote: I think i didn't understand you well, but when you enter on an interrupt its a good idea to disable ints ( cli ) and when you exit from it enable all interrupts ( sti ). So you can put cli at the beginning of your ISR and sti at the end.
Really? Than what is the outportb(0x20,0x20); for?

You do not need to use sti and cli in interrupts. All interrupts will stop until you send a message to the pic stating that the interrupt is over, by doing this:
mov al, 0x20
out 0x20, al

...
eL JeDi

Re:2 problems - one thread

Post by eL JeDi »

Hi solar ray,
Really? Than what is the outportb(0x20,0x20); for?
I am refering to the ISRs.. not the IRQ.

when enter in IRQs, i explain it here:
If you are talking about IRQ, ( in ex the timer ).....
All interrupts will stop until you send a message to the pic stating that the interrupt
I'm agree with that, but what about int 0,1,2...?
Is that what you quoted and answered

And i don't want to begin any discuss, but first you can read my post instead of answer the same that I have said before.
Tim

Re:2 problems - one thread

Post by Tim »

cmp wrote:my first question is: is there any way to determine, wheter an interrupt suspended another interrupt?
eg: i got my timer interrupt switching the tasks, but i'dont want a task to be switch, if a interupt is currently running
The CPU won't tell you if the ISR is being called from inside another ISR, and you can't reliably tell from the PIC. However, it's easy to keep track of how many levels of interrupt nesting you have (just increment a variable when you enter an ISR and decrement it when you leave).
the second question is: how can i determine the sector size of a disk, must i rely on the first sector (with fat there's a sector size statement, but what's with non fat disks?)?
Different storage devices have different ways of reporting their size. IDE devices support the IDENTIFY command, which will tell you the device's size in terms of both cylinders/heads/sectors and total sectors; you should use the total sector count since its limit is a lot greater.

In general, floppy drives don't know how big the floppy in the drive is. You can either try seeking to the largest track number possible, and keep reducing that until the seek is successful. However, that takes time and would probably result in a grating sound from the floppy disk. You should be able to assume that any file system format which supports floppy drives keeps track of the total size somewhere (e.g. the boot sector for FAT).
cmp

Re:2 problems - one thread

Post by cmp »

ok, thanks for the answers.
The CPU won't tell you if the ISR is being called from inside another ISR, and you can't reliably tell from the PIC. However, it's easy to keep track of how many levels of interrupt nesting you have (just increment a variable when you enter an ISR and decrement it when you leave).
yeah, i've thought about a solution of this kind, but the problem is, i would have to hook all interrupts avaible and i thik it's not an appropriate solution.
is there nothing done like this the hardware-way?
damn, if you could recode soms instruction, like you can recode the interupts, my problem would be solved

@ the sector problem
ok, i think i'll check the fs statements of the sectorsize
Tim

Re:2 problems - one thread

Post by Tim »

If you don't handle a certain interrupt then why would you care if that interrupt was being processed? To put it another way: you're writing the OS. You will handle anything that happens to the machine. Anything that you don't handle, can't happen.
Post Reply