Hi Krishnan,

I use m5threads, which is a light-weight alternative for pthread, to
simulate multi-threaded programs in the SE mode:
https://github.com/gem5/m5threads
(I'm not sure if there are any other ways.)

Thanks,
Hossein


On Sat, Jul 24, 2021 at 11:00 AM krishnan gosakan via gem5-users <
gem5-users@gem5.org> wrote:

> Hi all,
> I am trying to run a code with pthread in gem5 se mode. The code runs
> perfectly when launched from command prompt but pthread_create returns
> error code 11 when run in se mode. Is there anything special I should do to
> make pthread run in se mode. From the tests directory, I see that C++
> std::thread is running perfectly in gem5 se mode. Any help would be
> appreciated.
> Thank you.
>
> Sample code I use in gem5 se mode
>
> #include <stdio.h>
> #include <pthread.h>
>
> void *doWork1(void *arg)
> {
>     for (int i=0; i<1000000000; i++)
>         ;
>     printf("work completed\n");
> }
>
> int main()
> {
>     pthread_t thread;
>     int error = pthread_create(&thread, NULL, doWork1, NULL);
>     if (error == 0)
>     {
>         printf("thread created\n");
>         pthread_join(thread, NULL);
>         printf("thread work complete\n");
>     }
>     else
>     {
>         printf("error in thread creation %d\n",error);
>     }
>     return 0;
> }
>
> --
> Regards,
> Krishnan.
> _______________________________________________
> gem5-users mailing list -- gem5-users@gem5.org
> To unsubscribe send an email to gem5-users-le...@gem5.org
> %(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
_______________________________________________
gem5-users mailing list -- gem5-users@gem5.org
To unsubscribe send an email to gem5-users-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to