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).
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
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
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
On Mon, 02 Mar 2015 09:05:42 +
Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk wrote:
Mattias Gaertner wrote:
On Sat, 28 Feb 2015 19:20:49 +
Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk wrote:
[...]
Looking at
Mattias Gaertner wrote:
On Sat, 28 Feb 2015 19:20:49 +
Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk wrote:
[...]
Looking at
http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial#Initialization_and_Finalization
there are dire warnings that TThread.Create()
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 wiki
On Sat, 28 Feb 2015 19:20:49 +
Mark Morgan Lloyd markmll.fpc-pas...@telemetry.co.uk 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.
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 think
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 forever,
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
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
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, it
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,
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 mar...@stack.nl:
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
2015-02-26 18:50 GMT+08:00 Henry Vermaak henry.verm...@gmail.com:
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
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
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/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
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
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 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 overhead is
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
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 is
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
2015-02-25 22:47 GMT+08:00 Dmitry Boyarintsev skalogryz.li...@gmail.com:
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
2015-02-25 23:16 GMT+08:00 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);
until ...
This seems not what I want. I would like to
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 xrf...@gmail.com:
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 -
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
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.
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 of the
I mean T.Suspend, so u resume it then suspend it
25.02.2015, 18:16, hinsta...@yandex.ru 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;
Assunto: Re: [fpc-pascal] Use sleep in thread
2015-02-25 23:16 GMT+08:00 hinsta...@yandex.rumailto: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
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;
36 matches
Mail list logo