Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #1150

Re: Threadpool engien and scalability [1]

Path csiph.com!usenet.pasdenom.info!gegeweb.org!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "aminer" <aminer@videotron.ca>
Newsgroups comp.programming.threads, comp.programming
Subject Re: Threadpool engien and scalability [1]
Date Mon, 1 Oct 2012 14:02:55 -0500
Organization A noiseless patient Spider
Lines 109
Message-ID <k4clsk$3mf$1@dont-email.me> (permalink)
References <k4ci68$8ho$1@dont-email.me>
Injection-Date Mon, 1 Oct 2012 18:03:00 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="c43ca82f9e8d62a602307fe9d2e9b807"; logging-data="3791"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX189399RVz5uzojRDs77Be0p"
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6157
X-RFC2646 Format=Flowed; Response
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
Cancel-Lock sha1:wo2OAyxUvwVfxCHF3o66YKYXQCk=
X-Priority 3
X-MSMail-Priority Normal
Xref csiph.com comp.programming.threads:1150 comp.programming:2275

Cross-posted to 2 groups.

Show key headers only | View raw


It's a socialist soldier from in the heart of America !


http://www.youtube.com/watch?v=S5FCdx7Dn0o




Amine Moulay Ramdane.


"aminer" <aminer@videotron.ca> wrote in message 
news:k4ci68$8ho$1@dont-email.me...
> Hello,
>
> I have corrected my mistakes , please read again:
>
> If you take a look at my threadpool engine:
>
> http://pages.videotron.com/aminer/
>
> you will notice that it does not scale in the execute() method
> cause LockedIncLong(balance1) is expensive.
>
> here is the execute method:
>
> ==
>
> function TThreadPool.execute(func:TMyProc;const Context: Pointer): 
> Boolean;
>
> var
> local_balance,local_count:long;
>
> params: PParams;
> p:pointer;
>
> begin
> new(params);
> setlength(params^,1);
> params^[0].proc:=func;
> params^[0].data:=context;
>
> local_balance:=LockedIncLong(balance1) mod FThreadCount;
> while not Queues[local_balance].push(tobject(params)) do sleep(0);
> events[local_balance].setevent;
> end;
>
> ===
>
> Now to be able to scale the execute() method we have to add a new
> execute1() method that will be called from mutiple threads, i have to
> use LockedIncLong() but it will be called only once:
>
> ==
>
> function TThreadPool.execute1(func:TMyProc;const Context:
> Pointer;index:long): Boolean;
>
> params: PParams;
> p:pointer;
>
> begin
> new(params);
> setlength(params^,1);
> params^[0].proc:=func;
> params^[0].data:=context;
>
> if index = 0
> then
> begin
> index:=LockedIncLong(balance1) mod FThreadCount;
> end;
>
> while not Queues[index].push(tobject(params)) do sleep(0);
> events[index].setevent;
> end;
>
> =
>
>
> so we have to call the execute1() method from mutiple threads like this:
>
> and we have to initialize index to zero before:, like this:
>
> ThreadPool.execute1(myproc,data,index)
>
> I am using mutiple lockfree FIFO queues inside my threadpool engine,
> so that there is less contention and using work-stealing also, so after
> adding execute1() methods , this threadpool engine will become scalable.
> this threadpool engine can also be used as a scalable queue
> (not a strict FIFO queue, but it's also useful).
>
> This threadpool engine is useful and that is what's important.
>
>
>
> I will try to update my threadpol engine soon.
>
>
>
> Thank you,
> Amine Moulay Ramdane.
>
>
>
> 

Back to comp.programming.threads | Previous | NextPrevious in thread | Find similar


Thread

Threadpool engien and scalability [1] "aminer" <aminer@videotron.ca> - 2012-10-01 12:59 -0500
  Re: Threadpool engien and scalability [1] "aminer" <aminer@videotron.ca> - 2012-10-01 13:34 -0500
  Re: Threadpool engien and scalability [1] "aminer" <aminer@videotron.ca> - 2012-10-01 13:48 -0500
  Re: Threadpool engien and scalability [1] "aminer" <aminer@videotron.ca> - 2012-10-01 14:02 -0500

csiph-web