Hello,
We are college students working on adding multi process functionality to the simple OS that is used for teaching at our college.
We have an idea on how to make it happened, but we hit a major wall that doesn't allow us to progress forward.
The problem that we are getting is that when we try to load a process that the whole OS freezes, but the program GUI loads.
We have a test program in the OS that uses keyboard input, but when the GUI loads we can't do nothing. We can't even press the key that is used to terminate the program.
Is there something that is blocking the interrupts?
We suspect that the problem may lie somewhere around the interrupt return after loading a new process.
We would really appreciate any kind of help, because we don't have much time to get this finished.
Thanks in advance.
P.S. the code for now can only load one more process beside the one that is always running.
P.P.S. This is in real mode, not protected mode.
app_start equ 0A000 ;This is where the program is loaded into memory
task_offset equ 1000h
stack_size equ 512
stack_bottom equ 9000h
stack_point equ stack_bottom - 1020h
process_state equ stack_bottom - 1040h
app_seg_now: dw 0
init_int: ; overriding the int 1Ch
pusha
cli
push es
xor ax, ax
mov es, ax
mov ax, RoundRobin
mov [es:1Ch*4], ax
mov ax, cs
mov [es:1Ch*4+2], ax
push ds
pop gs
pop es
sti
popa
ret
_scheduler_init: ; this is what the kernel calls
call init_int
ret
RoundRobin: ; our int routine
push gs
pop ds
jmp change_task
reset_count:
xor ax,ax
mov [current], ax
jmp _Continue
change_task:
cli
push ax
push bx
push cx
push dx
push si
push di
push bp
mov ax, sp
mov bx, [current]
shl bx, 1
add bx, stack_point
mov [bx], ax
mov ax,1
add [current],ax
mov ax, [current]
cmp ax, [total]
je reset_count
_Continue:
mov bx, [current]
shl bx, 1
add bx, process_state
mov ax, 1
cmp [bx], ax ; if the process already loaded
je Add_process
add bx, 20h ; this is the distance between the pointer of the process's SP and the pointer of the process's state
mov ax, [bx]
mov sp, ax
pop bp
pop di
pop si
pop dx
pop cx
pop bx
pop ax
sti
iret
Add_process:
mov sp, stack_bottom
mov ax, 0
mov [bx], ax
pushf
push cs
push app_start
sti
iret
Task_Init: ; this is called when the process is loaded into memory
push ax
push bx
mov ax, 1
add [total], ax
mov ax,[total]
sub ax, 1
mov bx, ax
shl bx, 1
add bx, process_state
mov ax, 1
mov [bx], ax
pop bx
pop ax
ret
total: dw 1
current: dw 0