Thread creation in Wine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi guys,

I was looking at the thread creation API.
Exactly, why do we use PTHREAD_SCOPE_SYSTEM instead of PTHREAD_SCOPE_PROCESS ?
http://source.winehq.org/git/wine.git/?a=blob;f=dlls/ntdll/thread.c#l611

What is the technical difference?
I remember, some years ago, that on SunOS 8 setting the latter it would make one thread only scheduled globally for the process, instead, using the first would let the process use at the same time multiple threads on multiple processors (so a proper multithread application).

Today I tested it with Ubuntu 8.10 and gcc/g++ 4.3.2 and actually there's no difference (on my Intel dual core).
Anyone does know what is the benefit from switching from one to other option?

Attaching some stupid code used by MT testing:

Code:

#include <iostream>
#include <cmath>
#include <pthread.h>

extern "C" void *my_th(void *param) {
	const unsigned int 	CNT=1024;
	double 			mysum=0.0;
	for(unsigned int j = 0; j< CNT; j++)
		for(unsigned int k=0; k < CNT; k++)
			for(unsigned int i=0; i<CNT; i++)
				mysum += i;
	std::cout << "mysum: " << mysum << std::endl;
	return 0;
}

int main(int argc, char *argv[]) {
	pthread_t	pthread_id, pthread_id2;
	pthread_attr_t	attr;

	pthread_attr_init(&attr);
	pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS);
	std::cout << "first thread: " << pthread_create(&pthread_id, &attr, my_th, 0) << std::endl;
	std::cout << "second thread: " << pthread_create(&pthread_id2, &attr, my_th, 0) << std::endl;
	pthread_attr_destroy(&attr);
	pthread_join(pthread_id, 0);
	pthread_join(pthread_id2, 0);
}



Compile with g++ -o test -pthread test.cpp.

Cheers,






[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux