Main Page | Report this Page
Linux Forum Index  »  Linux Development - Applications  »  Futex Wait Called...
Page 1 of 1    

Futex Wait Called...

Author Message
pandi...
Posted: Thu Oct 22, 2009 5:44 pm
Guest
I am working on fedora core 7, kernel version 2.6.21, gcc version
4.1.2. I have my user space application which communicate with my char
driver using write and read system calls. I have a thread in
application to send data to driver and concurrently a signal handler
(user space) is register. write calls is invoking continuously and
read call is also invoking continuously on notification from driver.
Here am facing a problem of "futex_wait" at one time. Even though my
user space application has no mutex locking, FUTEX_WAIT is called and
nothing proceeds after this.

I got below lines form strace of my process and always getting lock at
same address.

--- SIGRT_15 (Real-time signal 13) at (no spam) 0 (0) ---
futex(0x4aa700b0, FUTEX_WAIT, 2, NULL

please guide me to solve this issue or what could be reason for above
things.

if need any more info, i will give u.
 
Christof Meerwald...
Posted: Mon Oct 26, 2009 12:38 pm
Guest
On Thu, 22 Oct 2009 20:44:17 -0700 (PDT), pandi wrote:
Quote:
I am working on fedora core 7, kernel version 2.6.21, gcc version
4.1.2. I have my user space application which communicate with my char
driver using write and read system calls. I have a thread in
application to send data to driver and concurrently a signal handler
(user space) is register. write calls is invoking continuously and

Note that the set of functions your are allowed to use in a signal handler
is very limited (i.e. only async signal safe functions). To me it looks like
you are trying to call a non async signal safe function which causes the
problem.

Can you show use the code for the signal handler?


Christof

--
http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
 
pandi...
Posted: Tue Nov 24, 2009 6:38 am
Guest
Hi,

Sorry for delayed reply since i was in another work.

The code you asked is below
==========================================================================={
int i = 0, j = 0,k=0;
int bytes_rcvd;
int ret;
int file_close;
static int rcv_pkt_length =0;
unsigned long StaticStreamBuffer[4] = { 0,0,0,0 };
char fc[10];
char f2f[10] ;
int len = 0;

if(error_handler==1)
{
printf("Error handler called\n");
scanf("%c",&g);
}
gpstAppData ->s32Length = 4096;
gpstAppData ->s8CID = gConnectionInfo[0]->lCID;
gpstAppData->s8DID = gConnectionInfo[0]->lDID;
gpstAppData->s8Priority = gConnectionInfo[0]->Priority;
gpstAppData->s8F2Flag = gConnectionInfo[0]->F2Flag;

printf("Called Signal_Handler1\n");
StaticStreamBuffer[0] = gConnectionInfo[0]->lCID;
StaticStreamBuffer[1] = gConnectionInfo[0]->lDID;

ret = ioctl(gConnectionInfo[0]->filedes, UNI_GET_EVENTINFO,
StaticStreamBuffer);
if (ret < 0)
{
printf("Ioctl Failed\n");
}
gpstAppData ->s8CID = gConnectionInfo[0]->lCID;
gpstAppData->s8DID = gConnectionInfo[0]->lDID;
gpstAppData->s8Priority = gConnectionInfo[0]->Priority;
gpstAppData->s8F2Flag = gConnectionInfo[0]->F2Flag;

gpstAppData ->s32Length = StaticStreamBuffer[1] + StaticStreamBuffer
[2];
length = StaticStreamBuffer[1];
printf("Event ID = %d\n", StaticStreamBuffer[0]);
printf("Length Received = %d\n", StaticStreamBuffer[1]);
printf("OverFlow Length = %d\n", StaticStreamBuffer[2]);
bytes_rcvd = read(gConnectionInfo[0]->filedes, gpstAppData,
gpstAppData->s32Length);
fwrite(gpstAppData->aBuffer, sizeof(char), bytes_rcvd,
gConnectionInfo[0]->fWrite);
//scanf("%c",&i);
//rcv_pkt_length += bytes_rcvd;
system("> /var/log/messages");
//printf("bytes_rcvd for tc0 =%d\n", bytes_rcvd);
gConnectionInfo[0]->bytes_rcvd += bytes_rcvd;

printf("bytes_rcvd for tc0 =%d,gConnectionInfo[0]->bytes_rcvd=%d
\n",bytes_rcvd,gConnectionInfo[0]->bytes_rcvd);
if (StaticStreamBuffer[0] == 0 && (gConnectionInfo[0]->bytes_rcvd =gpstAppData->s32Length))
{
printf("Iteration=%d,last descriptor\n", iter);
rcv_pkt_length = 0;
gConnectionInfo[0]->bytes_rcvd = 0;
printf("test........................\n");
/*************************************/
file_close = fclose(gConnectionInfo[0]->fWrite);
if (!file_close)
{
printf("Tc0 - file closed successfully\n");
printf(" file transferred = %d\n", file_no_tc0);

}
else
{
printf("Failed to close the file handle\n");
}
gConnectionInfo[0]->fWrite = NULL;


#if 1
if (Compare())
{
printf("Test1\n");
fprintf(fcheck,"failed=> comparision file no =%d\n",file_no_tc0);
fclose(fcheck);
if(gpstAppData1->aBuffer!=NULL)
free(gpstAppData1->aBuffer);
if(gpstAppData->aBuffer!=NULL)
free(gpstAppData->aBuffer);
if(gpstAppData1!=NULL)
free(gpstAppData1);
if(gpstAppData!=NULL)
free(gpstAppData);
exit(0);
}
#endif
system("echo ==============after a write============== >> /home/
info.txt");
system("cat /proc/meminfo >> /home/info.txt");

file_no_tc0 = file_no_tc0 + 1;

#if 0
if (file_no_tc0 ==43)
{
Terminate();
while(1)
{
system("echo -e \"\\007\" >/dev/tty10 ");
sleep(1);
}
printf("terminate...............\n");
exit(0);
}
#endif
printf(" tx_file_no = %d\n", tx_file_no);
tx_file_no = tx_file_no + 1;
#if 1
if (file_no_tc0 ==43)
{

fprintf(fcheck,"passed %d sl_bl_pm=%d\n",s8Priority,sl_bl_pm);

sl_bl_pm = sl_bl_pm+2;
file_no_tc0 =1;
file_no_tc1 =1;
tx_file_no =1;
if(s8Priority ==1 && sl_bl_pm>Cool
{
Terminate();
fclose(fcheck);
while(0)
{
system("echo -e \"\\007\" >/dev/tty10 ");
sleep(1);
}
printf("terminate...............\n");
exit(0);
}
else if(s8Priority ==0 && sl_bl_pm>Cool
{
Terminate();
s8Priority =1;
sl_bl_pm = 2;
Establish_Connection();
}
SetBurstLengthPwrMode();
}
#endif

strcpy(gConnectionInfo[0]->rx_file, "/home/TestFiles/r\0");
strcpy(file_name, "");
sprintf(file_name, "%d", file_no_tc0);
strcat(gConnectionInfo[0]->rx_file, file_name);
printf("tc0 - gConnectionInfo[0]->rx_file=%s\n",
gConnectionInfo[0]->rx_file);
gConnectionInfo[0]->fWrite = fopen(gConnectionInfo[0]->rx_file,
"wb");
/*************************************/
//changed
receive_complete = 1;
}
printf("futex RX Checking1\n");
}
===========================================================================Thanks

pandi


On Oct 26, 11:38 pm, Christof Meerwald <NOSPAM-seeMySig
+uf... at (no spam) usenet.cmeerw.org> wrote:
Quote:
On Thu, 22 Oct 2009 20:44:17 -0700 (PDT), pandi wrote:
I am working on fedora core 7, kernel version 2.6.21, gcc version
4.1.2. I have my user space application which communicate with my char
driver using write and read system calls. I have a thread in
application to send data to driver and concurrently a signal handler
(user space) is register. write calls is invoking continuously and

Note that the set of functions your are allowed to use in a signal handler
is very limited (i.e. only async signal safe functions). To me it looks like
you are trying to call a non async signal safe function which causes the
problem.

Can you show use the code for the signal handler?

Christof

--http://cmeerw.org                             sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org
 
pandi...
Posted: Tue Nov 24, 2009 6:40 am
Guest
Hi

If you need any more information..please let me know...

Thanks

On Nov 24, 9:38 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Quote:
Hi,

Sorry for delayed reply since i was in another work.

The code you asked is below
===========================================================================> {
  int i = 0, j = 0,k=0;
  int bytes_rcvd;
  int ret;
  int file_close;
  static int rcv_pkt_length =0;
  unsigned long StaticStreamBuffer[4] = { 0,0,0,0 };
  char  fc[10];
  char  f2f[10] ;
  int   len  = 0;

if(error_handler==1)
{
        printf("Error handler called\n");
        scanf("%c",&g);}

  gpstAppData ->s32Length = 4096;
  gpstAppData ->s8CID = gConnectionInfo[0]->lCID;
  gpstAppData->s8DID = gConnectionInfo[0]->lDID;
  gpstAppData->s8Priority = gConnectionInfo[0]->Priority;
  gpstAppData->s8F2Flag = gConnectionInfo[0]->F2Flag;

  printf("Called Signal_Handler1\n");
  StaticStreamBuffer[0] = gConnectionInfo[0]->lCID;
  StaticStreamBuffer[1] = gConnectionInfo[0]->lDID;

  ret = ioctl(gConnectionInfo[0]->filedes, UNI_GET_EVENTINFO,
StaticStreamBuffer);
  if (ret < 0)
  {
    printf("Ioctl Failed\n");
  }
  gpstAppData ->s8CID = gConnectionInfo[0]->lCID;
  gpstAppData->s8DID = gConnectionInfo[0]->lDID;
  gpstAppData->s8Priority = gConnectionInfo[0]->Priority;
  gpstAppData->s8F2Flag = gConnectionInfo[0]->F2Flag;

  gpstAppData ->s32Length = StaticStreamBuffer[1] + StaticStreamBuffer
[2];
  length = StaticStreamBuffer[1];
  printf("Event ID = %d\n", StaticStreamBuffer[0]);
  printf("Length Received = %d\n", StaticStreamBuffer[1]);
  printf("OverFlow Length = %d\n", StaticStreamBuffer[2]);
  bytes_rcvd = read(gConnectionInfo[0]->filedes, gpstAppData,
gpstAppData->s32Length);
  fwrite(gpstAppData->aBuffer, sizeof(char), bytes_rcvd,
gConnectionInfo[0]->fWrite);
  //scanf("%c",&i);
  //rcv_pkt_length += bytes_rcvd;
  system("> /var/log/messages");
  //printf("bytes_rcvd for tc0 =%d\n", bytes_rcvd);
  gConnectionInfo[0]->bytes_rcvd += bytes_rcvd;

  printf("bytes_rcvd for tc0 =%d,gConnectionInfo[0]->bytes_rcvd=%d
\n",bytes_rcvd,gConnectionInfo[0]->bytes_rcvd);
  if (StaticStreamBuffer[0] == 0 && (gConnectionInfo[0]->bytes_rcvd => gpstAppData->s32Length))
  {
    printf("Iteration=%d,last descriptor\n", iter);
    rcv_pkt_length = 0;
    gConnectionInfo[0]->bytes_rcvd = 0;
    printf("test........................\n");
  /*************************************/
 file_close = fclose(gConnectionInfo[0]->fWrite);
   if (!file_close)
    {
      printf("Tc0 - file closed successfully\n");
      printf(" file transferred = %d\n", file_no_tc0);

    }
    else
    {
      printf("Failed to close the file handle\n");
    }
    gConnectionInfo[0]->fWrite = NULL;

#if 1
        if (Compare())
        {
                printf("Test1\n");
                fprintf(fcheck,"failed=> comparision file no =%d\n",file_no_tc0);
               fclose(fcheck);
                        if(gpstAppData1->aBuffer!=NULL)
                        free(gpstAppData1->aBuffer);
                        if(gpstAppData->aBuffer!=NULL)
                        free(gpstAppData->aBuffer);
                        if(gpstAppData1!=NULL)
                                free(gpstAppData1);
                        if(gpstAppData!=NULL)
                                free(gpstAppData);
           exit(0);
        }
#endif
     system("echo ==============after a write============== >> /home/
info.txt");
    system("cat /proc/meminfo >> /home/info.txt");

    file_no_tc0 = file_no_tc0 + 1;

        #if 0
            if (file_no_tc0 ==43)
                {
                Terminate();
        while(1)
        {
        system("echo -e \"\\007\" >/dev/tty10 ");
        sleep(1);
        }
        printf("terminate...............\n");
              exit(0);
                }
        #endif
        printf(" tx_file_no = %d\n", tx_file_no);
        tx_file_no = tx_file_no + 1;
        #if 1
         if (file_no_tc0 ==43)
         {

            fprintf(fcheck,"passed %d sl_bl_pm=%d\n",s8Priority,sl_bl_pm);

                sl_bl_pm = sl_bl_pm+2;
                file_no_tc0 =1;
                file_no_tc1 =1;
                tx_file_no =1;
                if(s8Priority ==1 && sl_bl_pm>Cool
                {
                        Terminate();
                        fclose(fcheck);
                        while(0)
                        {
                        system("echo -e \"\\007\" >/dev/tty10 ");
                        sleep(1);
                        }
                        printf("terminate................\n");
                exit(0);
                }
                else if(s8Priority ==0 && sl_bl_pm>Cool
                {
                        Terminate();
                        s8Priority =1;
                        sl_bl_pm = 2;
                        Establish_Connection();
                }
                SetBurstLengthPwrMode();
        }
        #endif

    strcpy(gConnectionInfo[0]->rx_file, "/home/TestFiles/r\0");
    strcpy(file_name, "");
    sprintf(file_name, "%d", file_no_tc0);
    strcat(gConnectionInfo[0]->rx_file, file_name);
    printf("tc0 - gConnectionInfo[0]->rx_file=%s\n",
gConnectionInfo[0]->rx_file);
    gConnectionInfo[0]->fWrite = fopen(gConnectionInfo[0]->rx_file,
"wb");
            /*************************************/
    //changed
            receive_complete = 1;
 }
   printf("futex RX Checking1\n");}

===========================================================================> Thanks

pandi

On Oct 26, 11:38 pm, Christof Meerwald <NOSPAM-seeMySig

+uf... at (no spam) usenet.cmeerw.org> wrote:
On Thu, 22 Oct 2009 20:44:17 -0700 (PDT), pandi wrote:
I am working on fedora core 7, kernel version 2.6.21, gcc version
4.1.2. I have my user space application which communicate with my char
driver using write and read system calls. I have a thread in
application to send data to driver and concurrently a signal handler
(user space) is register. write calls is invoking continuously and

Note that the set of functions your are allowed to use in a signal handler
is very limited (i.e. only async signal safe functions). To me it looks like
you are trying to call a non async signal safe function which causes the
problem.

Can you show use the code for the signal handler?

Christof

--http://cmeerw.org                            sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org
 
Christof Meerwald...
Posted: Wed Nov 25, 2009 4:33 pm
Guest
On Tue, 24 Nov 2009 08:38:33 -0800 (PST), pandi wrote:
Quote:
Sorry for delayed reply since i was in another work.

The code you asked is below

If that's the code of the signal handler, then please have a look at
http://linux.die.net/man/2/signal for a list of async-signal-safe functions
(most of the functions you are using are not async-signal-safe).


Christof

--
http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org
 
pandi...
Posted: Wed Nov 25, 2009 9:24 pm
Guest
Ok thanks...I will go through the link and let you know if i will have
any clarifications.

On Nov 26, 2:33 am, Christof Meerwald <NOSPAM-seeMySig
+uy... at (no spam) usenet.cmeerw.org> wrote:
Quote:
On Tue, 24 Nov 2009 08:38:33 -0800 (PST), pandi wrote:
Sorry for delayed reply since i was in another work.

The code you asked is below

If that's the code of the signal handler, then please have a look athttp://linux.die.net/man/2/signalfor a list of async-signal-safe functions
(most of the functions you are using are not async-signal-safe).

Christof

--http://cmeerw.org                             sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org
 
pandi...
Posted: Wed Nov 25, 2009 11:09 pm
Guest
Hi,

My application uses following calls that is not mentioned in link you
sent,
================ioctl
mmap2
ummap
fstat64
rt_sigaction
rt_sigpromask
================is above of any one makes my application hangs?

Please confirm since am not facing this problem periodically it is
very rare....

Thanks

On Nov 26, 12:24 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Quote:
Ok thanks...I will go through the link and let you know if i will have
any clarifications.

On Nov 26, 2:33 am, Christof Meerwald <NOSPAM-seeMySig

+uy... at (no spam) usenet.cmeerw.org> wrote:
On Tue, 24 Nov 2009 08:38:33 -0800 (PST), pandi wrote:
Sorry for delayed reply since i was in another work.

The code you asked is below

If that's the code of the signal handler, then please have a look athttp://linux.die.net/man/2/signalfora list of async-signal-safe functions
(most of the functions you are using are not async-signal-safe).

Christof

--http://cmeerw.org                            sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org                   xmpp:cmeerw at cmeerw.org
 
 
Page 1 of 1    
All times are GMT - 5 Hours
The time now is Sat Nov 28, 2009 6:50 am