When you work in a multithreaded environment, then you should go
through all your system functions and make sure if there is not a
multihread alternative system function for it. This saved me a lot of
headache when I worked with threads.

Here are some multithread timerelated functions you need to use in a
multihread environment:
ctime_r, localtime_r, gmtime_r, ascteim_r

Werner


On Mon, 2 Apr 2001, Liu, Guangsheng wrote:

> Hi,
>   I got the following problem with localtime() when I create 10 thread. The
> main problem is also attached.
> However, if I create 2 or 3 thread, it works fine.
>   Any clue.
>   Thanks.
>
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x40953709 in chunk_alloc (ar_ptr=0x409e8d60, nb=24) at malloc.c:2763
> 2763    malloc.c: No such file or directory.
> (gdb) bt
> #0  0x40953709 in chunk_alloc (ar_ptr=0x409e8d60, nb=24) at malloc.c:2763
> #1  0x409535ce in __libc_malloc (bytes=15) at malloc.c:2696
> #2  0x40958a29 in __strdup (s=0x409e1731 "/etc/localtime") at strdup.c:43
> #3  0x409833c0 in tzset_internal (always=24) at tzset.c:169
> #4  0x409840db in __tz_convert (timer=0xbffff834, use_localtime=1,
> tp=0x409ee460) at tzset.c:582
> #5  0x4097fc9c in localtime (t=0xbffff834) at localtime.c:43
> #6  0x8057d61 in main (argc=3, argv=0xbffff8c4) at testt.c:75
> (gdb)
>
> testt.c
> int main()
> {
>         struct timeb start, end;
>       struct tm *ploc_t0;
>       struct tm *ploc_t1;
>
>         ftime(&start);
>
>       for (i=0; i<threads; i++)
>       {
>         //create 10 threads.
>       }
>
>         for (i=0; i<threads; i++)
>       {
>          pthread_join(t[i], 0);
>       }
>
>       ftime(&end);
>         ploc_t0 = localtime(&start.time);
>         ploc_t1 = localtime(&end.time);
>         ...
> }
>
>
>
> _______________________________________________
> Redhat-devel-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-devel-list
>



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to