I've got a problem with interrupt flag being reset.
After setting the interrupt flag to 0 with asm cli
, it comes to a line of code char* c = new char[size]
, and when it finishes initializing that array, it resets the I flag to 1. How can i make it that flag I stays on current value the whole time, because writing another asm cli
after the new[] operator isn't the solution, giving that i have gap between those 2 instructions which enables the interrupts?
Thread::Thread(StackSize stackSize, Time timeSlice) {
#ifndef BCC_BLOCK_IGNORE
DIS_INT // a macro: #define DIS_INT asm cli
#endif
myPCB = new PCB(stackSize,timeSlice,this);
#ifndef BCC_BLOCK_IGNORE
ENB_INT
#endif
}
this is where i set I flag to 0 and call the PCB constructor
PCB::PCB(StackSize stackSize, Time timeSlice, Thread* thread){
time = timeSlice;
myThread = thread;
stack = createStack(stackSize);
...
char* PCB::createStack(StackSize stackSize){
char* stek = new char[stackSize]; // after this line, IF = 1
#ifndef BCC_BLOCK_IGNORE // which is not desired
newSS = FP_SEG(stek+stackSize);
newSP = FP_OFF(stek+stackSize);
asm{
mov oldSS, ss
mov oldSP, sp
mov ss, newSS
mov sp, newSP
push ax
push bx
push cx
push dx
push es
push ds
push si
push di
push bp
mov newSS, ss
mov newSP, sp
mov ss, oldSS
mov sp, oldSP
}
this->stekp = MK_FP(newSS,newSP);
#endif
return stek;
}