*Hi again*
*I've tried what you told me about the multi-threaded workload like this:*

for i in xrange(np):
    p = LiveProcess()
    p.cmd = ['/home/anoir/m5threads/lock_test/test_lock']
    system.cpu[i].workload = p
    system.cpu[i].createThreads()



*but i get this error message:*Beginning simulation!
info: Entering event queue @ 0.  Starting simulation...
warn: CP14 unimplemented crn[0], opc1[6], crm[3], opc2[4]
[main]a rwlock is initialized
[main]a rwlock is initialized
[main]a rwlock is initialized
[main]a rwlock is initialized


1. read lock test
1. read lock test
1. read lock test
1. read lock test
[main]a read lock is obtained
[main]a read lock is obtained
[main]a read lock is obtained
[main]a read lock is obtained
fatal: Called sys_clone, but no unallocated thread contexts found!
 @ tick 26207000
[cloneFunc:build/ARM/sim/syscall_emul.cc, line 875]
Memory Usage: 662792 KBytes
Program aborted at cycle 26207000
Aborted (core dumped)


*What could be wrong??*
*Please take a look at the test_lock code *


On Wed, Oct 12, 2016 at 4:42 PM, anoir nechi <anoirne...@gmail.com> wrote:

> Thank you Jason
>
> On Wed, Oct 12, 2016 at 4:39 PM, Jason Lowe-Power <ja...@lowepower.com>
> wrote:
>
>> This should work.
>>
>> Attached is a diff for the simple.py script in
>> configs/learning_gem5/part1/ that has 4 CPUs and runs hello 4 times.
>> Hopefully this helps.
>>
>> For a multithreaded application, I believe you'll use a similar config
>> script (instantiate multiple processes all with the same binary file path).
>> Then, the binaries should be linked to m5threads instead of pthreads.
>>
>> Jason
>>
>> On Mon, Oct 10, 2016 at 8:16 AM anoir nechi <anoirne...@gmail.com> wrote:
>>
>>>
>>>
>>> *Hi *
>>>
>>> *I wrote a configuration script for a multicore system based on ARM and
>>> it seems fine except for the workload. i wanted to try testing the
>>> configuration by assigning a hello world executable for each CPU.*
>>> *I tried creating different processes but I've got some indexing error
>>> then i made a for loop like this:*
>>> i=0
>>> for i in xrange(np):
>>>     process = LiveProcess()
>>>     process.cmd = ['tests/test-progs/hello/bin/arm/linux/hello']
>>>     system.cpu[i].workload = process
>>>     system.cpu[i].createThreads()
>>> *and all i get is this :*
>>> Global frequency set at 1000000000000 ticks per second
>>> warn: DRAM device capacity (4096 Mbytes) does not match the address
>>> range assigned (512 Mbytes)
>>> 0: system.remote_gdb.listener: listening for remote gdb #0 on port 7000
>>> 0: system.remote_gdb.listener: listening for remote gdb #1 on port 7001
>>> 0: system.remote_gdb.listener: listening for remote gdb #2 on port 7002
>>> 0: system.remote_gdb.listener: listening for remote gdb #3 on port 7003
>>>
>>> *it suppose to show 4 x Hello World!. i don't understand the problem!!*
>>>
>>> *One other thing, i know that to use a multithreaded application  I have
>>> to use the m5threads, But, do I have to apply some changes to my
>>> configuration script to support the multithreaded applications ?*
>>>
>>> *Thank you*
>>>
>>> *PS : Attached the configuration script*
>>> --
>>> *Anouar NECHI*
>>>
>>>
>>> *IT Engineer : Industrial systemsHigher Institute of Computer Science*
>>>
>>>
>>> _______________________________________________
>>>
>>> gem5-users mailing list
>>>
>>> gem5-users@gem5.org
>>>
>>> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
>>
>>
>> _______________________________________________
>> gem5-users mailing list
>> gem5-users@gem5.org
>> http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users
>>
>
>
>
> --
> *Anouar NECHI*
>
>
> *IT Engineer : Industrial systemsHigher Institute of Computer ScienceTunis
> - El Manar University*
> *Phone :* *(+216) 50 311 536 <%28%2B216%29%2050%20311%20536>*
> *E-mail :* *anoirne...@gmail.com <anoirne...@gmail.com>*
>



-- 
*Anouar NECHI*


*IT Engineer : Industrial systemsHigher Institute of Computer ScienceTunis
- El Manar University*
*Phone :* *(+216) 50 311 536*
*E-mail :* *anoirne...@gmail.com <anoirne...@gmail.com>*
/*
    m5threads, a pthread library for the M5 simulator
    Copyright (C) 2009, Stanford University

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>

static pthread_rwlock_t lock;
static pthread_mutex_t trylock = PTHREAD_MUTEX_INITIALIZER;

void* run1(void* arglist)
{
    pthread_t id = pthread_self();
    printf("[run1] TID=%d\n", (int)id);

    printf("[run1] started\n");

    pthread_rwlock_rdlock(&lock);
    printf("[run1] a read lock is obtained\n");

    pthread_rwlock_unlock(&lock);
    printf("[run1] a read lock is released\n");

    return NULL;
}


void* run2(void* arglist)
{
    printf("[run2]started\n");

    int res = pthread_mutex_trylock(&trylock);
    printf("[run2] try lock result %d\n", res);

    if (res == 0) {
        pthread_mutex_unlock(&trylock);
    }
    return NULL;
}

int main(int argc, const char** const argv) {

    pthread_t pth;
    pthread_attr_t attr;
    int arg;

    pthread_attr_init(&attr);
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);

    pthread_rwlock_init(&lock, NULL);
    printf("[main]a rwlock is initialized\n");

    // test 1 : read lock 
    printf("\n1. read lock test\n");

    pthread_rwlock_rdlock(&lock);
    printf("[main]a read lock is obtained\n");

    pthread_create(&pth, &attr, run1, &arg);
    printf("[main]thread created with run1\n");

    pthread_join(pth, NULL);
    printf("[main]thread joined\n");

    pthread_rwlock_unlock(&lock);
    printf("[main]a read lock is released\n");

    // test 2 : write lock 
    printf("\n2. write lock test\n");

    pthread_rwlock_wrlock(&lock);
    printf("[main]a write lock is obtained\n");

    pthread_create(&pth, &attr, run1, &arg);
    printf("[main]thread created with run1\n");

    int i;
    for (i = 0; i < 10; i++) {
        printf("[main]idling %d\n", i);
    }

    pthread_rwlock_unlock(&lock);
    printf("[main]a write lock is released\n");

    pthread_rwlock_destroy(&lock);

    pthread_join(pth, NULL);
    printf("[main]thread joined\n");

    // test 3 : try lock 
    printf("\n3. try lock test\n");

    // 3.1 trylock will be tried to an occupied lock
    pthread_mutex_lock(&trylock);
    printf("[main]a lock is obtained\n");

    pthread_create(&pth, &attr, run2, &arg);
    printf("[main]thread created with run2\n");

    pthread_join(pth, NULL);
    printf("[main]thread joined\n");

    pthread_mutex_unlock(&trylock);
    printf("[main]a lock is released\n");

    // 3.2 trylock will be tried to a free lock
    pthread_create(&pth, &attr, run2, &arg);
    printf("[main]thread created with run2\n");

    pthread_join(pth, NULL);
    printf("[main]thread joined\n");
}
_______________________________________________
gem5-users mailing list
gem5-users@gem5.org
http://m5sim.org/cgi-bin/mailman/listinfo/gem5-users

Reply via email to