Timothy R. Chavez wrote:
>>-int set_affinity(int cpuid)
>>+int set_affinity(int thread_id)
> 
> 
> This argument seems pointless to me.  In main_thread, where you call
> create_fifo_thread, you'll want to initialize the thread arguments to
> NULL, rather than cpuid, because, as you've already established, it's
> not guaranteed the CPU corresponding to that cpuid is actually online
> until it is actually tested.  We can then get rid of the argument to
> set_affinity all together and update all the callers.  Do you agree?

Right, I can do it in another way: no arg but return choosen cpu.

> 
> 
>> {
>>      int tid = gettid();
>>      cpu_set_t mask;
>>+     static int cpuid = 0;
>>+
>>+     pthread_mutex_lock(&mutex_cpu);
>>+     do {
>>+             CPU_ZERO(&mask);
>>+             CPU_SET(cpuid, &mask);
>>+
>>+             if (!sched_setaffinity(0, sizeof(mask), &mask)) {
>>+                     printf ("Thread %d affinity set to 
>>cpu%d\n",thread_id,cpuid);
> 
> 
> thread_id != tid
> 
> Should probably also follow convention,
> 
> "Thread %d: Affinity set to..."

I'll change that too.


Cheers.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to