Le 25/02/2015 15:41, Xiangrong Fang a écrit :
Hi All,
Can I use Sleep() in a thread to give up cpu time to other threads
running at the same time, so as to adjust the relative "niceness" of a
group of workers working on the same subject (in which each thread
take part of the whole task).
Th
On 2015-03-02 06:13, Luca Olivetti wrote:
> create it
> suspended and start it at the end of the creator.
Very good advice. I always create them suspended, and never had any
serious issues with threads.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
htt
Michael Schnell wrote:
On 02/28/2015 08:20 PM, Mark Morgan Lloyd wrote:
Looking at
http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
there are dire warnings that TThread.Create() shouldn't be overridden.
???
The Docs say "Normally you a
On Mon, 02 Mar 2015 09:05:42 +
Mark Morgan Lloyd wrote:
> Mattias Gaertner wrote:
> > On Sat, 28 Feb 2015 19:20:49 +
> > Mark Morgan Lloyd wrote:
> >
> >> [...]
> >> Looking at
> >> http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
>
On 02/28/2015 08:20 PM, Mark Morgan Lloyd wrote:
Looking at
http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
there are dire warnings that TThread.Create() shouldn't be overridden.
???
The Docs say "Normally you are required to override
Mattias Gaertner wrote:
On Sat, 28 Feb 2015 19:20:49 +
Mark Morgan Lloyd wrote:
[...]
Looking at
http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
there are dire warnings that TThread.Create() shouldn't be overridden.
That is nonse
El 01/03/15 a les 22:34, fredvs ha escrit:
> Ooops, in previous mail you should read (sorry)=>
>
>>> there are dire warnings that TThread.Create() shouldn't be overridden.
>>> Should this be in the documentation if it's a significant issue?
>
>> It's the first time I hear it, I've been doing it
On Sat, 28 Feb 2015 19:20:49 +
Mark Morgan Lloyd wrote:
>[...]
> Looking at
> http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
>
> there are dire warnings that TThread.Create() shouldn't be overridden.
That is nonsense. Unless you pl
Ooops, in previous mail you should read (sorry)=>
>> there are dire warnings that TThread.Create() shouldn't be overridden.
>> Should this be in the documentation if it's a significant issue?
> It's the first time I hear it, I've been doing it forever, just like in
> the example in the same wik
>> there are dire warnings that TThread.Create() shouldn't be overridden.
>> Should this be in the documentation if it's a significant issue?
> It's the first time I hear it, I've been doing it forever, just like in
> the example in the same wiki page.
Hum... same for me here... ;-(
Do you th
El 28/02/15 a les 20:20, Mark Morgan Lloyd ha escrit:
> Looking at
> http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
> there are dire warnings that TThread.Create() shouldn't be overridden.
> Should this be in the documentation if it's a sign
Marco van de Voort wrote:
In our previous episode, Xiangrong Fang said:
BUT, that cannot be used to prioritize a thread. While you block a thread
using rtlevent, it can only be unblocked from another thread. While you use
sleep(), it still get time share of the CPU, only that it does nothing
unt
On 02/26/2015 03:34 PM, Xiangrong Fang wrote:
That's even better.
As said: sleep() does make sense when used for the purpose it's provided
for (by the OS). And in that use, it imposes the lowest possible overhead.
-Michael
___
fpc-pascal maillist
2015-02-26 21:53 GMT+08:00 Marco van de Voort :
>
> No, basically a sleeping thread is marked in the scheduler as "do not
> schedule for nn
> ticks". The thread doesn't run to evaluate if it should contiue. That is
> the
> scheduler/kernel's task.
>
> That's even better. And the key point is, aft
In our previous episode, Xiangrong Fang said:
> BUT, that cannot be used to prioritize a thread. While you block a thread
> using rtlevent, it can only be unblocked from another thread. While you use
> sleep(), it still get time share of the CPU, only that it does nothing
> until sleep finishes, ri
On Thu, Feb 26, 2015 at 09:23:33PM +0800, Xiangrong Fang wrote:
> I use rtlevent, but only meant to maintain a pool of threads, while there
> is no task for a thread it is blocked waiting for an event.
>
> BUT, that cannot be used to prioritize a thread. While you block a thread
> using rtlevent,
2015-02-26 18:50 GMT+08:00 Henry Vermaak :
> >
> > Sleep is for granting the CPU for other processes for (at least) a
> > predefined time.
> >
> > See the mail of the original poster: this is what he asked for.
>
>
Thats right.
> This is incorrect, since if you pause a thread with sleep(), you
On 02/26/2015 11:50 AM, Henry Vermaak wrote:
Obviously CPU the overhead is a lot greater than with just calling sleep.
. Regarding the context ;-)
-Michael
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/c
On Thu, Feb 26, 2015 at 11:40:44AM +0100, Michael Schnell wrote:
> On 02/26/2015 11:33 AM, Henry Vermaak wrote:
> >Blocking with an even will sleep until someone wakes you up, it's
> >very efficient. Using sleep() you will have to wake up, check if
> >someone needs you, go to sleep again, etc. This
On 02/26/2015 11:33 AM, Henry Vermaak wrote:
Blocking with an even will sleep until someone wakes you up, it's very
efficient. Using sleep() you will have to wake up, check if someone
needs you, go to sleep again, etc. This is obviously more inefficient.
We were talking about the overhead of a
On Thu, Feb 26, 2015 at 11:20:41AM +0100, Michael Schnell wrote:
> On 02/26/2015 11:14 AM, Michael Schnell wrote:
> >I don't know what this does.
> With stepping in ASM I verified that (after some calculation) it
> does just a single syscall (via a "sysenter" Assembler instruction).
>
> so the ove
On 02/26/2015 11:14 AM, Michael Schnell wrote:
I don't know what this does.
With stepping in ASM I verified that (after some calculation) it does
just a single syscall (via a "sysenter" Assembler instruction).
so the overhead is minimal.
-Michael
On 02/26/2015 10:50 AM, Marco van de Voort wrote:
??? Afaik they are the procedural counterpart of TEvents, and I think
that using them is cheaper than sleep, since you only unblock when
needed.
??? I _thought_ sleep would just call the appropriate OS function but in
fact it does
Function
In our previous episode, Michael Schnell said:
> > You may use RTLEvents to pause a thread. =>
> >
> Obviously CPU the overhead is a lot greater than with just calling sleep.
??? Afaik they are the procedural counterpart of TEvents, and I think that
using them is cheaper than sleep, since you only
On 02/25/2015 09:17 PM, fredvs wrote:
Hello.
You may use RTLEvents to pause a thread. =>
Obviously CPU the overhead is a lot greater than with just calling sleep.
-Michael
___
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
http://lists.free
Hello.
You may use RTLEvents to pause a thread. =>
Program Project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
Classes;
Type
{ THelloThread }
THelloThread = class(TThread)
fSleepTime,fThreadNum:integer;
fEvent:PRTLEvent;
procedure Execute; override;
synchronising tools do not do what you want?
De: fpc-pascal-boun...@lists.freepascal.org
em nome de Xiangrong Fang
Enviado: quarta-feira, 25 de fevereiro de 2015 12:33
Para: FPC-Pascal users discussions
Assunto: Re: [fpc-pascal] Use sleep in thread
2015-02
2015-02-25 23:16 GMT+08:00 :
> not sure if this helps, but:
> for example, if you want thread T to run using approx. 70% of max.
> available capacity, try this:
>
> repeat
> T.Resume;
> Sleep(70);
> T.Resume;
> Sleep(30);
> until ...
>
This seems not what I want. I would like to schedule
On Wed, Feb 25, 2015 at 06:17:17PM +0300, hinsta...@yandex.ru wrote:
> I mean T.Suspend, so u resume it then suspend it
TThread.Suspend and TThread.Resume are deprecated (since 2.4.4), don't
use them.
Henry
___
fpc-pascal maillist - fpc-pascal@lists.
On 02/25/2015 03:41 PM, Xiangrong Fang wrote:
Can I use Sleep() in a thread to give up cpu time to other threads
running at the same time
AFAIK:
Sleep(n) makes the thread give up CPU for _at_least_ n milliseconds
Sleep(0) makes it give up it's current time slice and is due to be
re-schedule
On Wed, Feb 25, 2015 at 10:41:58PM +0800, Xiangrong Fang wrote:
> Hi All,
>
> Can I use Sleep() in a thread to give up cpu time to other threads running
> at the same time, so as to adjust the relative "niceness" of a group of
> workers working on the same subject (in which each thread take part o
I mean T.Suspend, so u resume it then suspend it
25.02.2015, 18:16, "hinsta...@yandex.ru" :
> not sure if this helps, but:
> for example, if you want thread T to run using approx. 70% of max. available
> capacity, try this:
>
> repeat
> T.Resume;
> Sleep(70);
> T.Resume;
> Sleep(30);
> u
not sure if this helps, but:
for example, if you want thread T to run using approx. 70% of max. available
capacity, try this:
repeat
T.Resume;
Sleep(70);
T.Resume;
Sleep(30);
until ...
so T runs for 70 ms, then sleeps for 30 ms, etc
25.02.2015, 18:06, "Xiangrong Fang" :
> 2015-02-25 22:
2015-02-25 22:47 GMT+08:00 Dmitry Boyarintsev :
> I presume most of the systems would make the sleeping thread to yield the
> execution time for other threads.
> The questionable behavior might occur in case of sleep(0); (should it
> yield the remaining time or just return immediately - up to the
I presume most of the systems would make the sleeping thread to yield the
execution time for other threads.
The questionable behavior might occur in case of sleep(0); (should it
yield the remaining time or just return immediately - up to the OS).
And multi-cpu might also do something different.
t
Hi All,
Can I use Sleep() in a thread to give up cpu time to other threads running
at the same time, so as to adjust the relative "niceness" of a group of
workers working on the same subject (in which each thread take part of the
whole task).
Thanks!
Xiangrong
___
36 matches
Mail list logo