mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 02:32:51 +02:00
* use pthread_kill() for Suspend/Resume in cthreads
git-svn-id: trunk@5280 -
This commit is contained in:
parent
7cc78b6ae1
commit
edafc80d8c
@ -60,6 +60,8 @@ function pthread_cond_destroy(_para1:Ppthread_cond_t):cint;cdecl;external 'c' n
|
||||
function pthread_cond_init(_para1:Ppthread_cond_t;_para2:Ppthread_condattr_t):cint;cdecl;external 'c' name 'pthread_cond_init';
|
||||
function pthread_cond_signal(_para1:Ppthread_cond_t):cint;cdecl;external 'c' name 'pthread_cond_signal';
|
||||
function pthread_cond_wait(_para1:Ppthread_cond_t;_para2:Ppthread_mutex_t):cint;cdecl;external 'c' name 'pthread_cond_wait';
|
||||
function pthread_kill(__thread:pthread_t; __signo:cint):cint;cdecl;external 'c';
|
||||
|
||||
|
||||
function sem_init(__sem:Psem_t; __pshared:cint;__value:cuint):cint;cdecl; external 'c' name 'sem_init';
|
||||
function sem_destroy(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_destroy';
|
||||
|
@ -62,6 +62,7 @@ function pthread_cond_destroy(_para1:Ppthread_cond_t):cint;cdecl;external;
|
||||
function pthread_cond_init(_para1:Ppthread_cond_t;_para2:Ppthread_condattr_t):cint;cdecl;external;
|
||||
function pthread_cond_signal(_para1:Ppthread_cond_t):cint;cdecl;external;
|
||||
function pthread_cond_wait(_para1:Ppthread_cond_t;_para2:Ppthread_mutex_t):cint;cdecl;external;
|
||||
function pthread_kill(__thread:pthread_t; __signo:cint):cint;cdecl;external;
|
||||
|
||||
function sem_init(__sem:Psem_t; __pshared:cint;__value:dword):cint;cdecl; external;
|
||||
function sem_destroy(__sem:Psem_t):cint;cdecl;external ;
|
||||
|
@ -193,18 +193,7 @@ begin
|
||||
CurrentTM.SemaphoreWait(FSem);
|
||||
end else begin
|
||||
FSuspendedExternal := true;
|
||||
// naughty hack if the user doesn't have Linux with NPTL...
|
||||
// in that case, the PID of threads will not be identical
|
||||
// to the other threads, which means that our thread is a normal
|
||||
// process that we can suspend via SIGSTOP...
|
||||
// this violates POSIX, but is the way it works on the
|
||||
// LinuxThreads pthread implementation. Not with NPTL, but in that case
|
||||
// getpid(2) also behaves properly and returns the same PID for
|
||||
// all threads. Thats actually (FINALLY!) native thread support :-)
|
||||
if FPid <> GMainPID then begin
|
||||
FSuspended := true;
|
||||
fpkill(FPid, SIGSTOP);
|
||||
end;
|
||||
SuspendThread(FHandle);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -219,11 +208,7 @@ begin
|
||||
end;
|
||||
end else begin
|
||||
FSuspendedExternal := false;
|
||||
// see .Suspend
|
||||
if FPid <> GMainPID then begin
|
||||
FSuspended := False;
|
||||
fpkill(FPid, SIGCONT);
|
||||
end; end;
|
||||
ResumeThread(FHandle);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -158,6 +158,7 @@ function pthread_cond_destroy(_para1:Ppthread_cond_t):cint;cdecl;external 'c' n
|
||||
function pthread_cond_init(_para1:Ppthread_cond_t;_para2:Ppthread_condattr_t):cint;cdecl;external 'c' name 'pthread_cond_init';
|
||||
function pthread_cond_signal(_para1:Ppthread_cond_t):cint;cdecl;external 'c' name 'pthread_cond_signal';
|
||||
function pthread_cond_wait(_para1:Ppthread_cond_t;_para2:Ppthread_mutex_t):cint;cdecl;external 'c' name 'pthread_cond_wait';
|
||||
function pthread_kill(__thread:pthread_t; __signo:cint):cint;cdecl;external 'c';
|
||||
|
||||
function sem_init(__sem:Psem_t; __pshared:cint;__value:cuint):cint;cdecl; external 'c' name 'sem_init';
|
||||
function sem_destroy(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_destroy';
|
||||
|
@ -249,13 +249,13 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
||||
|
||||
function CSuspendThread (threadHandle : TThreadID) : dword;
|
||||
begin
|
||||
{$Warning SuspendThread needs to be implemented}
|
||||
result := pthread_kill(threadHandle,SIGSTOP);
|
||||
end;
|
||||
|
||||
|
||||
function CResumeThread (threadHandle : TThreadID) : dword;
|
||||
begin
|
||||
{$Warning ResumeThread needs to be implemented}
|
||||
result := pthread_kill(threadHandle,SIGCONT);
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user