systan
asked on
Is it possible that multithreading wont work if my core is only 1
hi
I've build a basic multithreading of record type via tmemorystream
type
tmythread = class(tthread)
private
MStream:TmemoryStream;
StreamRec: pmyStreamRec; //packed record type
xscore: integer;
retvalue: integer;
procedure showStatus;
protected
procedure execute; override;
constructor Create(createsuspended:boo lean);
end;
...
var mythreads: array[0..max-1] of tmythread;
...
mythreads[0] := tmythread.Create(true);
mythreads[0].MStream := db.tptStream1;
mythreads[0].StreamRec := db.StreamRec1;
mythreads[0].Resume;
mythreads[1] := tmythread.Create(true);
mythreads[1].MStream := db.tptStream2;
mythreads[1].StreamRec := db.StreamRec2;
mythreads[1].Resume;
...
Number of seconds WITHOUT using class tthread: 12s+-
Number of seconds USING class tthread with 2 threads: 12s+-
There the same.
What if I test this on dual core or quad core?, What possibly is the result?
What is your analysis?
I've build a basic multithreading of record type via tmemorystream
type
tmythread = class(tthread)
private
MStream:TmemoryStream;
StreamRec: pmyStreamRec; //packed record type
xscore: integer;
retvalue: integer;
procedure showStatus;
protected
procedure execute; override;
constructor Create(createsuspended:boo
end;
...
var mythreads: array[0..max-1] of tmythread;
...
mythreads[0] := tmythread.Create(true);
mythreads[0].MStream := db.tptStream1;
mythreads[0].StreamRec := db.StreamRec1;
mythreads[0].Resume;
mythreads[1] := tmythread.Create(true);
mythreads[1].MStream := db.tptStream2;
mythreads[1].StreamRec := db.StreamRec2;
mythreads[1].Resume;
...
Number of seconds WITHOUT using class tthread: 12s+-
Number of seconds USING class tthread with 2 threads: 12s+-
There the same.
What if I test this on dual core or quad core?, What possibly is the result?
What is your analysis?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi Geert;
I don't understand what you mean.
I have only 1 core cpu, with intel celeron 1.6hz and free memory 500mb.
my bad for not having a detail.
I don't understand what you mean.
I have only 1 core cpu, with intel celeron 1.6hz and free memory 500mb.
my bad for not having a detail.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah, I forgot to tell : Of course a multithreaded application will work on 1 Core machine.
But as I said, get some gains from that is another story
But as I said, get some gains from that is another story
ASKER
Thanks
systan,
you are lacking the knowledge about the ins and outs of multithreading
as you don't get the basics you won't be able to grasp the answers
> finding the bottlenecks
> protecting the shared resources
> synchronizing multiple threads
> dividing tasks into smaller pieces in multiple threads
> using a threadpool
> reporting back out of the threads
read up on these topics:
http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/ToC.html
or download here :
http://cc.embarcadero.com/item/14809
covering a lot:
http://delphi.about.com/od/kbthread/Threading_in_Delphi.htm
you are lacking the knowledge about the ins and outs of multithreading
as you don't get the basics you won't be able to grasp the answers
> finding the bottlenecks
> protecting the shared resources
> synchronizing multiple threads
> dividing tasks into smaller pieces in multiple threads
> using a threadpool
> reporting back out of the threads
read up on these topics:
http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/ToC.html
or download here :
http://cc.embarcadero.com/item/14809
covering a lot:
http://delphi.about.com/od/kbthread/Threading_in_Delphi.htm
oh ... forgot what i find the state of the art piece for multithreading
check the OTL ! (OmniThreadLibrary)
http://www.thedelphigeek.com/
check the OTL ! (OmniThreadLibrary)
http://www.thedelphigeek.com/
where is the indenting ?
and the implementation of the threads ?