On 03/06/2013 11:45 AM, Florian Klaempfl wrote:
So (as with all x86 variants) no library
or system call is necessary.

Wrong. This is not true in the general case, please read the appropriate api documents.
I do know that on Windows it's documented like this by Microsoft. But I also know that the Microsoft C compiler (and AFAIK, gnu as well) does not adhere to that documentation but simply uses the appropriate selector register that the Intel chip designers happily provided for such kind of purpose. (We already discussed this here some years ago.)

Wrong. On linux this can be done by a jump to a certain adress.
OK. I did not thoroughly enough check into this. Does the jump to the system region automatically provide the mode switch without changing anything in the MMU (and this without the necessity to invalid the cache) ?

If yes a glibc library call might provide a noticeable overhead and it might be advantageous to do the system call directly in the RTL.


And how does one the "current" TThread?

Do you mean something like this:


Type
TMyThread = class(TThread)
 private
  currentthread: Integer;
end.

var
  threads: array[1..100] of TMyThread;

for i := 1 to 100 do begin
  thread[i] := TMyThread.Create;
  thread[i].currentthread := i;
end;


TMyThread.Execute;
var
  s: String;
begin
  s := 'I am ' + InToString(currentthread);
end;

?
-Michael
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to