Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-09

Thread problem

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Paul Renaud

IHello,

I'm having a problem with the OS/2 version of the compiler.

This simplified version of my program keeps generating an exception when compiled and run in EComStation 1.2, OS/2 versions 4.5 and 4 but runs fine when compiled for Windows.

Program Test1( Input, Output );
{$S+}
  Const
    StackSize = 1000000;
    
    Max_Array = 5000;
  Type
    Data_Array = packed array[ 0 .. Max_Array ] of LongInt;
  Function MyThread( P: Pointer ): PtrInt;
    Var
      Data: Data_Array;
      Indexer: LongInt;
    Begin
      MyThread := 0;
      For Indexer := 1 to Max_Array do
        Data[ Indexer ] := 0;
    End;  
    
  Var
    Handle: LongWord;
    My_Result: LongInt;
  Begin
    WriteLn( 'Test1 starting' );
    My_Result := BeginThread( @MyThread, Nil, Handle, StackSize );
    My_Result := WaitForThreadTerminate( Handle, 0 );
    WriteLn( 'Test1 finished' );
  End.

The error generated is...

SYS1808:
The process has stopped.  The sofware diagnostic
code (exception code) is  0005.

the command I used to compile it is:

fpc Test1.pas -Se -gl

This exception appears to be generated before my thread gets control, so I can't install my own exception handlers to intercept it.

Any help would be appreciated.
Thanks,
Paul.

Reply by email

Travis Siegel
to Paul Renaud

I'm not sure it works properly on windows.

When I modify this to start two threads, and print out messages based on their start/stop times, as well as a message inside the thread, I get both ending messages before I get only a single printout from within the threaded function.  This seems to indicate windows isn't starting two threads, though I don't have a clue how to verify this.

Just thought I'd add fuel to the fire here. :)

Paul Renaud wrote 63 lines
I Hello, I'm having a problem with the OS/2 version of the compiler. This simplified version of my program keeps generating an exception when compiled and run in EComStation 1.2, OS/2 versions 4.5 and 4 but runs fine when compiled for Windows. Program Test1( Input, Output ); {$S+}   Const     StackSize = 1000000;     Max_Array = 5000;   Type     Data_Array = packed array[ 0 .. Max_Array ] of LongInt;   Function MyThread( P: Pointer ): PtrInt;     Var       Data: Data_Array;       Indexer: LongInt;     Begin       MyThread := 0;       For Indexer := 1 to Max_Array do         Data[ Indexer ] := 0;     End;   Var     Handle: LongWord;     My_Result: LongInt;   Begin     WriteLn( 'Test1 starting' );     My_Result := BeginThread( @MyThread, Nil, Handle, StackSize );     My_Result := WaitForThreadTerminate( Handle, 0 );     WriteLn( 'Test1 finished' );   End. The error generated is... SYS1808: The process has stopped.  The sofware diagnostic code (exception code) is  0005. the command I used to compile it is: fpc Test1.pas -Se -gl This exception appears to be generated before my thread gets control, so I can't install my own exception handlers to intercept it. Any help would be appreciated. Thanks, Paul. _______________________________________________ fpc-pascal maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email