oops, that was wrong :(

here is the possible solution:
static void delete_threadinfo(void)
{
    struct threadinfo *threadinfo;

    threadinfo = getthreadinfo();
    list_destroy(threadinfo->joiners, NULL);
    close(threadinfo->wakefd_recv);
    close(threadinfo->wakefd_send);
    THREAD(threadinfo->number) = NULL;
    active_threads--;
    if (threadinfo->number < next_threadnumber)
        next_threadnumber = threadinfo->number;
    gw_assert(threadinfo != &mainthread);
    gw_free(threadinfo);
}

next_threadnumber is always the min. free slot number.
worst case while creating new thread: 
        next_threadnumber is used then max MAX_THREATABLE_SIZE-next_threadnumber 
loop.

Am Donnerstag, 19. Juni 2003 18:52 schrieb Alexander Malysh:
> Hi,
>
> Am Donnerstag, 19. Juni 2003 18:36 schrieb Stipe Tolj:
> > Michael Mulcahy schrieb:
> > > Hi All,
> > >
> > > Found a solution that I think should be ok.
> > >
> > > In the gwthread-module the table is size 1024.
> > > While the thread number may increase byond it the
> > > id is a modulo of 1024 and so the modulo can be
> > > used in the log.c to prevent the prior mentioned
> > > problem.
> > >
> > > suggested fix would be to use following:
> > >
> > >         if ((e = thread_to[(gwthread_self()%1024)])) {
> > >
> > > Have tested this and appears to work.
> >
> > how about having this inside gwthread-pthread.c as function:
> >
> > /* Return the threadtable sloot this thread is using. */
> > long gwthread_table_slot(void)
> > {
> >     return (gwthread_self() % THREADTABLE_SIZE);
> > }
> >
> > and use this call instead of gwthread_self() for the logging
> > functions?!
>
> how about just reusing of freed thread number for next tread ?
>
> static void delete_threadinfo(void)
> {
>     struct threadinfo *threadinfo;
>
>     threadinfo = getthreadinfo();
>     list_destroy(threadinfo->joiners, NULL);
>     close(threadinfo->wakefd_recv);
>     close(threadinfo->wakefd_send);
>     THREAD(threadinfo->number) = NULL;
>     active_threads--;
>     next_threadnumber = threadinfo->number; /* reuse tread numer */
>     gw_assert(threadinfo != &mainthread);
>     gw_free(threadinfo);
> }
>
> > Stipe
> >
> > [EMAIL PROTECTED]
> > -------------------------------------------------------------------
> > Wapme Systems AG
> >
> > Vogelsanger Weg 80
> > 40470 Düsseldorf
> >
> > Tel: +49-211-74845-0
> > Fax: +49-211-74845-299
> >
> > E-Mail: [EMAIL PROTECTED]
> > Internet: http://www.wapme-systems.de
> > -------------------------------------------------------------------
> > wapme.net - wherever you are

-- 
Best regards / Mit besten Grüßen aus Köln

Dipl.-Ing.
Alexander Malysh
___________________________________

Centrium GmbH
Ehrenstrasse 2
50672 Köln

Fon: +49 (0221) 277 49 240
Fax: +49 (0221) 277 49 109

email: a.malysh at centrium.de
web: http://www.centrium.de
msn: olek2002 at hotmail.com
___________________________________________

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html


Reply via email to