32-bit PMode threading using Int 8... 
Author Message
 32-bit PMode threading using Int 8...

    My original post didn't get through, maybe it was server problems, or
maybe the robo/human moderator got the wrong impression based on a keyword,
I don't know, so I'm going to modify my post a little to represent my
question better. Here goes...

        I'm working on an Open Source (LGPL) cross platform multimedia
library, and one of the things I need for the DOS port is pre-emptive
multi-threading. I've tried everything, I've searched all over the 'Net,
I've read Intel's DOCs, I've read the DPMI spec, I've seen code snippets,
yet I can't find a "solution" to my problem. For now I just want something
that works, but I'm having trouble even getting something basic up and
running. Eventually I'll add stuff such as re-entrancy, semaphores, etc.

    I'm currently using TMT Pascal mixed with x86 assembly language. The
reason I'm telling you this is because I'm working in a 32-bit Protected
Mode environment. The threader _must_ run in a DOS window, as well as
straight DOS.

    The problem is that my code either completely freezes the computer (even
in a DOS window), or crashes after reporting the "before" values when it is
supposed to be waiting for a key press (more on this later).

    My current code looks as follows (in pseudo code, if you want actual
code it can be downloaded from
http://www.*-*-*.com/ )...

Timer Interrupt/Thread Scheduler
----------------------------------
push registers
push flags
far call old timer handler
use lss esp to switch to the current task's stack
pop registers
iretd

Add thread function
--------------------
if not initialized then return(false)
allocate a stack into local variable l_Stack
set thread's l_StackOfs to (l_Stack + StackSize)
save esp into a register
save ss into a register
set esp to l_StackOfs
set ss to ds
push eflags
push cs as a dword (ie: push word 0, then push cs)
push offset of programmer's function p_UserFunc
push all registers
save current esp into l_StackOfs
restore original esp
restore original ss
save l_StackOfs into thread's rESP
save ds into thread's rSS

Init threading function
----------------------
install timer handler (does not currently change the frequency of Int 8)
initialize globals used by threader
return(False) on error

Thread 1 (from main program)
-------------------------------
run as an infinite loop incrementing variable g_Thread1

Thread 2 (from main program)
-------------------------------
run as an inifinite loop incrementing variable g_Thread2

Main program
---------------
initialize threader
show g_Thread1, g_Thread2, g_Main "before" values
add Thread1 to threads
add Thread2 to threads
loop until keypressed, increment g_Main with each loop iteration
show g_Thread1, g_Thread2, g_Main "after" values
uninitialize threader

    Am I doing anything wrong?

Regards,
Orlando



Tue, 17 Aug 2004 04:55:58 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Division 32-Bit/32-Bit with 16-Bit Register

2. 16-bit SB-PRO/AWE-32 samples in Pmode and V86

3. 16 Bit C code using 32 bit Ext Mem

4. Using 16 bit fortran libraries with 32 bit fortran

5. Reading binary file generated from 32-bit machine using 64-bit machine

6. Building 32 bit DLL from 32 bit EXE

7. 32 Bit ASM from 32 Bit Windows COBOL

8. 32 Bit ASM from 32 Bit Windows COBOL

9. Calling 32-bit FORTRAN dlls from 32-bit VB

10. top 32 bits of 64-bit product of two 32-bit integers

11. 32-bit ST/V outruns 32-bit ST80 on Intel

12. HELP:32 bit VC++, _asm & int 13h

 

 
Powered by phpBB® Forum Software