|
@@ -461,6 +461,7 @@ TYPE
|
|
|
VAR
|
|
|
mainthread: Thread_t;
|
|
|
handler_done: BOOLEAN;
|
|
|
+ thread_exit: Key_t;
|
|
|
|
|
|
argc-: LONGINT; argv-: ADDRESS; environ-: ADDRESS;
|
|
|
|
|
@@ -717,7 +718,7 @@ VAR
|
|
|
|
|
|
PROCEDURE ThrExit*( );
|
|
|
BEGIN
|
|
|
- pthread_exit( 0 );
|
|
|
+ siglongjmp( pthread_getspecific( thread_exit ), 1 )
|
|
|
END ThrExit;
|
|
|
|
|
|
PROCEDURE ThrSetPriority*( thr: Thread_t; prio: LONGINT );
|
|
@@ -753,6 +754,8 @@ VAR
|
|
|
VAR
|
|
|
me: Thread_t;
|
|
|
old, new: Sigset;
|
|
|
+ state: ARRAY 2048 OF CHAR;
|
|
|
+
|
|
|
param: Sched_param;
|
|
|
res: WORD;
|
|
|
BEGIN
|
|
@@ -776,9 +779,9 @@ VAR
|
|
|
param.sched_priority := 0;
|
|
|
res := pthread_setschedparam( me, SCHED_RR, ADDRESSOF( param ) );
|
|
|
|
|
|
- proc();
|
|
|
+ ASSERT( pthread_setspecific( thread_exit, ADDRESSOF( state ) ) = 0 );
|
|
|
+ IF sigsetjmp( ADDRESSOF( state ), 0 ) = 0 THEN proc() END;
|
|
|
|
|
|
- pthread_exit( NIL );
|
|
|
RETURN NIL;
|
|
|
END Starter;
|
|
|
|
|
@@ -817,7 +820,7 @@ VAR
|
|
|
IF (thr # mainthread) THEN
|
|
|
pthread_detach( thr );
|
|
|
IF (thr = pthread_self()) THEN
|
|
|
- pthread_exit( 0 );
|
|
|
+ ThrExit
|
|
|
ELSE
|
|
|
pthread_cancel( thr );
|
|
|
END
|
|
@@ -859,7 +862,9 @@ VAR
|
|
|
low := sched_get_priority_min(SCHED_OTHER);
|
|
|
|
|
|
param.sched_priority := high;
|
|
|
- IF pthread_setschedparam( mainthread, SCHED_RR, ADDRESSOF( param ) ) # 0 THEN END;
|
|
|
+ ASSERT( pthread_setschedparam( mainthread, SCHED_RR, ADDRESSOF( param ) ) = 0 );
|
|
|
+
|
|
|
+ ASSERT( pthread_key_create( ADDRESSOF( thread_exit ), NIL ) = 0);
|
|
|
|
|
|
RETURN TRUE;
|
|
|
END ThrInitialize;
|