Timothy R. Chavez a écrit :
> Hey Gilles,
> 
> On Wed, 2008-10-22 at 13:51 +0200, Gilles Carry wrote:
>> From: gilles.carry <[EMAIL PROTECTED]>
>>
>> Syscall sched_setaffinity fails if choosen cpu is not online.
>> In set_affinity, thread_id value is used as cpuid when calling
>> sched_setaffinity. This fails when disabling cpus because threads ids
>> and online cpu ids don't necessarly match.
>>
>> This patch simply increments cpuid (max. 8192) until it finds an online cpu.
>> This guaranties that no more than one thread is assigned to one cpu.
>> If set_affinity is called more times than there are online cpus
>> then matrix_mult.c fails.
>>
>> Signed-off-by: Gilles Carry <[EMAIL PROTECTED]>
> 
> I just thought of something... 
> 
> main_thread:
> 
>     /* Create numcpus-1 concurrent threads */
>     for (j = 0; j < (numcpus-1); j++) {
>         tids[j] = create_fifo_thread(concurrent_thread, (void *)(intptr_t)j, 
> PRIO);
>                                                         ^^^^^^^^^^^^^^^^^^^
> This was originally being used as the "cpuid", right?  But no longer...
> 
>         if (tids[j] == -1) {
>             printf("Thread creation failed (max threads exceeded?)\n");
>             break;
>         }
>     }
> 
> 
> 
>> ---
>>  testcases/realtime/func/matrix_mult/matrix_mult.c |   58 
>> ++++++++++++++------
>>  1 files changed, 40 insertions(+), 18 deletions(-)
>>
>> diff --git a/testcases/realtime/func/matrix_mult/matrix_mult.c 
>> b/testcases/realtime/func/matrix_mult/matrix_mult.c
>> index 21fded8..a551687 100644
>> --- a/testcases/realtime/func/matrix_mult/matrix_mult.c
>> +++ b/testcases/realtime/func/matrix_mult/matrix_mult.c
>> @@ -44,6 +44,7 @@
>>  #include <libjvmsim.h>
>>  #include <libstats.h>
>>
>> +#define MAX_CPUS    8192
>>  #define PRIO                43
>>  #define MATRIX_SIZE 100
>>  #define DEF_OPS             8               /* the higher the number, the 
>> more CPU intensive */
>> @@ -66,15 +67,13 @@ static float criteria;
>>  static int *mult_index;
>>  static int *tids;
>>  static int *flags;
>> +static int online_cpu_id = -1;
>>
>>  stats_container_t sdat, cdat, *curdat;
>>  stats_container_t shist, chist;
>>  static pthread_barrier_t mult_start;
>> +static pthread_mutex_t mutex_cpu;
>>
>> -int gettid(void)
>> -{
>> -    return syscall(__NR_gettid);
>> -}
> 
> You shouldn't remove this... here's why...

It's no longer used here. Why leaving it?
Anyway this function is used in many tests. I think it shoulb be moved 
to librt.


> 
> Also, to bring this full circle... what then, is the point of passing
> 'j' as an argument to:
> 
> create_fifo_thread() when creating the concurrent threads... it's no
> longer useful, right?

True. I removed it and user thread->id instead.

Gilles.




-------------------------------------------------------------------------
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