C code

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.
Slasher

Re:C code

Post by Slasher »

hi,
A cpu can handle a large number of instructions in a fraction of a second, so disabling ints for a few instructions is okay.
if you don't you will get either a GPF 13, EXCEPTION 8, sometimes i got EXCEPTION 6 (invalid opcode/instruct, i was getting interrputed during task switching, stack changes etc) because the previous int wasn't completely handle before the next arrived. Also the PIC has a way of keeping a log of missed ints (i read somewhere, check intel docs)
Try disabling ints at the start of the IRS and enabling them again before you iret.
More care has to be taken if you are using TIMER INT for TASK SWITCHING!

If you are using TIMER INT for task switching you have to do something along these lines

disable int
save the running task's registers and co
(save new esp and/or ss register if using STACK BASED TASK SWITCHING)
schedule the next task
(restore esp and/or ss register from the new task to run if using STACK BASED TASK SWITCHING)
restore the new task's registers and co
acknowledge int to PIC
(now this is where you have to check the task's state)
if the task wasn't PREMPTED by TIMER WHILE RUNNING that means it performed a system call (eg SEND/RECIEVE) that cause another task to be scheduled
so all you do here is call RET
if the task was PREMPTED by the TIMER before,then you call IRET
hope this helps
jrfritz

Re:C code

Post by jrfritz »

Ok...

(Note to all the people complaining about my code and no source files and functions in my header files...i'm rewriting all that.)
Post Reply