I wrote a mutithreaded program using the clone() call. Memory allocation takes place only in the main thread. Preallocated structures like lists are then passed to the child threads. For I/O, I use the function fdopen, fdwrite, fdread, fdclose from the linux unit. This works ok for me.
A week ago I posted the following which contains a remark about thread safe error handling. I append it here, because I did not get any answers:
Show quoted text 45 lines
>Hello, developers,
>a happy new Year to all of You !
>I use fpc 1.0.4 and I missed the following syscalls:
>procedure getResUid(var ruid: longint; var euid:longint; var suid:longint);
>var
> regs : SysCallregs;
> x: longint;
>begin
>{ This was only for verifying that values are really set by system call:}
>(*
> ruid:=44;
> euid:=45;
> suid:=46;
>*)
> regs.reg2:=longint(@ruid);
> regs.reg3:=longint(@euid);
> regs.reg4:=longint(@suid);
>{ x:=}SysCall(SysCall_nr_getresuid,regs);
>{ writeln('X: ',x);}
> Linuxerror:=errno;
>end;
>procedure setResUid(var ruid: longint; var euid:longint; var suid:longint);
>var
> regs : SysCallregs;
> x: longint;
>begin
> regs.reg2:=ruid;
> regs.reg3:=euid;
> regs.reg4:=suid;
>{ x:=}
> SysCall(SysCall_nr_setresuid,regs);
>{ writeln('X: ',x);}
>{
> ruid:=regs.reg2;
> euid:=regs.reg3;
> suid:=regs.reg4;
>}
> Linuxerror:=errno;
>end;
>BTW, why does SysCall store errors in LinuxError? IMHO, it would be nice to make functions of all >>the syscalls and return
>error numbers as negative values. This would be inherently thread safe, or do I miss a point here?