/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this Pascal Free Pascal program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
500,000Make Error  523   

Read the ↓ make, command line, and program output logs to see how this program was run.

Read thread-ring benchmark to see what this program should do.

 notes

Free Pascal Compiler version 2.6.0 [2011/12/23] for x86_64

 thread-ring Pascal Free Pascal program source code

{ The Computer Language Benchmarks Game
  http://benchmarksgame.alioth.debian.org

  contributed by Marc Weustink
}

{$mode objfpc}

program thread_ring;

uses
  PThreads;

var
  SemList: array[1..503] of TSemaphore;

  ThreadAttr: TThreadAttr;
  ThreadFuncAddr: TStartRoutine;
  FinishedSem: TSemaphore;
  Count: Integer;
  
function ThreadFunc(AIndex: PtrInt): Pointer; cdecl;
var
  MySem, NextSem: PSemaphore;
  Id: TThreadID;
begin
  MySem := @SemList[AIndex];
  if AIndex < High(SemList)
  then begin
    NextSem := MySem+1;
    sem_init(NextSem, 0, 0);
    pthread_create(@Id, @ThreadAttr, ThreadFuncAddr, Pointer(AIndex+1));
  end
  else NextSem := @SemList[Low(SemList)];

  repeat
    sem_wait(MySem);
    if Count = 0 then begin
      WriteLn(Aindex);
      sem_post(FinishedSem);
    end
    else begin
      Dec(Count);
      sem_post(NextSem);
    end;
  until False;
end;


var
  n: Integer;
  Id: TThreadId;
begin
  Val(paramstr(1), count, n);
  if n <> 0 then exit;

  sem_init(SemList[Low(SemList)], 0, 1);
  sem_init(FinishedSem, 0, 0);

  pthread_attr_init(@ThreadAttr);
  pthread_attr_setdetachstate(@ThreadAttr, 1);
  pthread_attr_setstacksize(@ThreadAttr, 1024 * 16);

  ThreadFuncAddr := TStartRoutine(@ThreadFunc);
  pthread_create(@Id, @ThreadAttr, ThreadFuncAddr, Pointer(PtrUInt(Low(SemList))));

  sem_wait(FinishedSem);
end.

 make, command-line, and program output logs

Sat, 02 Feb 2013 01:57:11 GMT

MAKE:
mv threadring.fpascal threadring.pas
/usr/local/src/fpc-2.6.0.x86_64-linux/bin/fpc -FuInclude/fpascal -XXs -O3   -oFPASCAL_RUN threadring.pas
Free Pascal Compiler version 2.6.0 [2011/12/23] for x86_64
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling threadring.pas
threadring.pas(40,27) Error: Incompatible type for arg no. 1: Got "sem_t", expected "psem_t"
threadring.pas(57,33) Error: Incompatible type for arg no. 1: Got "sem_t", expected "psem_t"
threadring.pas(58,23) Error: Incompatible type for arg no. 1: Got "sem_t", expected "psem_t"
threadring.pas(67,23) Error: Incompatible type for arg no. 1: Got "sem_t", expected "psem_t"
threadring.pas(69) Fatal: There were 4 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/local/src/fpc-2.6.0.x86_64-linux/bin/ppcx64 returned an error exitcode (normal if you did not specify a source file to be compiled)
make: [threadring.fpascal_run] Error 1 (ignored)
mv FPASCAL_RUN threadring.fpascal_run
mv: cannot stat `FPASCAL_RUN': No such file or directory
make: [threadring.fpascal_run] Error 1 (ignored)
rm threadring.pas
0.04s to complete and log all make actions

COMMAND LINE:
./threadring.fpascal_run 500000

MAKE ERROR 

Revised BSD license

  Home   Conclusions   License   Play