Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » CoWork buggy!?
Re: CoWork buggy!? [message #14982 is a reply to message #14979] Mon, 24 March 2008 11:54 Go to previous messageGo to previous message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Mindtraveller wrote on Mon, 24 March 2008 10:48

As far as I understand, CoWork detects number of processors present and tries to execute threads on different cores. Is that so?


I had quite a nice time Twisted Evil analyzing "CoWork" (and multithreading under Ultimate++ in general) and sometimes I was painfully wrong Laughing , but eventually - withs Mirek's help, of course - Rolling Eyes I was able to document the whole stuff Very Happy . So just look at this doc cutting (also published in the hope that Mirek will correct possibly still lurking errors Rolling Eyes ):

Quote:

Cf. ...upp/uppsrc/Core/CoWork.cpp

Pool();

Starts number_of_cpu(_core)s_+_2 Threads which will wait for jobs and do them as soon as they are available.

That is: all these Threads are delivered to the OS to be called by the OS when appropriate.

That means: as soon as Pool is constructed, the machine-dependant maximum number of Threads is active (periodically called by the OS) and waiting for jobs to do.

What, in the end, is periodically called by the OS, are number_of_cpu(_core)s_+_2 ThreadRun-methods (identifiable by the index passed while running "Pool()").

CoWork::Pool::Pool()
{
for(int i = 0; i < CPU_Cores() + 2; i++) // cpu( core)s + 2
threads.Add().Run(callback1(&ThreadRun, i)); // add Thread to Pool & start Thread
}


Werner
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IsFinished() for CoWork
Next Topic: MT on Linux?
Goto Forum:
  


Current Time: Fri May 10 14:38:00 CEST 2024

Total time taken to generate the page: 0.02789 seconds