Thread creation in Wine

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Ema
Level 2
Level 2
Posts: 19
Joined: Fri Feb 13, 2009 6:58 pm

Thread creation in Wine

Post by Ema »

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/? ... ead.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 for MT testing:

Code: Select all

#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,
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Re: Thread creation in Wine

Post by vitamin »

Ema wrote: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/? ... ead.c#l611
You are asking this in the wrong place. This is Wine user forum. It's not Linux nor developers forum.
Ema
Level 2
Level 2
Posts: 19
Joined: Fri Feb 13, 2009 6:58 pm

Post by Ema »

Thanks but...where is the wine dev forum then?

Cheers,
vitamin
Moderator
Moderator
Posts: 6605
Joined: Sat Feb 23, 2008 2:29 pm

Post by vitamin »

Ema wrote:Thanks but...where is the wine dev forum then?
http://www.winehq.org/mailman/listinfo/wine-devel
Locked