[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

RE: [LI] Please Respond



Hi,
	Thanks. at last I got a helping hand. This following code will cause
seg faults in RedHat4.2  as well as in 5.1.
	But it didn't cause seg faults in redHat 6.0
	
	I seems that detaching or joining a thread after killing its waiting
on mutex/cond variable
	 causes seg faults. This problem is over come in
	6.0. This similar kind of problem is screwing up my project which is
based on RedHat 4.2 linux
	Expecting your reply
Bye



#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;
void * thread(void *buf)
{
        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL);
        pthread_mutex_lock(&mutex);
        while(1);
}
void main(void)
{
void fun(void);
        for(;;)
                fun();
}
 
void fun(void)
{
        pthread_t *pThread;
        int i;
        int nCount=6;
        int wCounter = 0;
        pThread=(pthread_t *)malloc(nCount*sizeof(pthread_t));
        for(;;)
        {
                wCounter++;
                if (wCounter % 100 == 0)
                  printf("Starting Threads Loop #%d.\n", wCounter);
 
                for(i=0;i<nCount;i++)
                        pthread_create(&pThread[i],NULL,thread,NULL);
 
                for(i=0;i<nCount;i++)
                {
                        pthread_cancel(pThread[i]);
                //      pthread_join(pThread[i],NULL);
                        pthread_detach(pThread[i]);
                }
        }
}



> -----Original Message-----
> From:	Nitin [SMTP:nitin@xxxxxxxxxxxxxxxxx]
> Sent:	Thursday, September 23, 1999 11:30 AM
> To:	GuruprasadM@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Subject:	Re: [LI] Please Respond
> 
> I am  using pthreads on RH 5.2 Not yet tried on RH 6.0. If you can
> describe your
> programes or send the code I may be able to help.
> 
> Nitin
> 
> "Guruprasad, Mahendrakar V (IE10)" wrote:
> 
> > Queries are not being answered
> >
> > > Hi all,
> > >       I have some problems with using pthread library. When I link  my
> > > code with pthread library
> > >       in RedHat 4.2 (Even in RedHat 5.1) & execute, its causing some
> > > undesirable results. But
> > >       when I link same code with pthread library in RedHat6.0 & run,
> it
> > > works perfectly. I feel there is
> > >       version problem with pthreadlibrary & I think they have fixed
> these
> > > problems in the newer version.
> > >       What should I do?? Is it possible to install this version of
> pthread
> > > library from  redHat 6.0 to 4.2??
> > >       Please reply.
> > >
> > > GURUPRASAD V.M.
> > > Honeywell India Software Operations
> > >
> > >
> > >
> > >
> > > --------------------------------------------------------------------
> > > For more information on Linux in India visit
> http://www.linux-india.org/
> > > The Linux India mailing list does not accept postings in HTML format.
> > --------------------------------------------------------------------
> > For more information on Linux in India visit http://www.linux-india.org/
> > The Linux India mailing list does not accept postings in HTML format.
- --------------------------------------------------------------------
For more information on Linux in India visit http://www.linux-india.org/
The Linux India mailing list does not accept postings in HTML format.

------------------------------