 |
|
| Linux Forum Index » Linux Development - Applications » Futex Wait Called... |
|
Page 1 of 2 Goto page 1, 2 Next |
|
| 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. |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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>
{
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>
{
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 |
|
|
| Back to top |
|
|
|
| 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>
{
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>
{
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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| 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 |
|
|
| Back to top |
|
|
|
| Christof Meerwald... |
Posted: Fri Nov 27, 2009 4:30 pm |
|
|
|
Guest
|
On Thu, 26 Nov 2009 01:09:16 -0800 (PST), pandi wrote:
Quote: 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?
What about printf, system, fwrite, fclose, ...?
Quote: Please confirm since am not facing this problem periodically it is
very rare....
But occasional crashes/deadlocks/... are the expected behaviour as it
depends when exactly the signal gets delivered (i.e. if some internal data
structure is left in an inconsistent state) - welcome to the world of race
conditions and undefined behaviour.
Christof
--
http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org |
|
|
| Back to top |
|
|
|
| pandi... |
Posted: Fri Nov 27, 2009 5:25 pm |
|
|
|
Guest
|
Hi
Many thanks for your reply for all my emails.
I got only system calls by running my application with strace ie.
(strace ./test)
Here is lines i got for my source code from the terminal window after
strace run...
===============================================================--- SIGRT_15 (Real-time signal 13) at (no spam) 0 (0) ---
write(1, "Called ReceivePkt_Handler1\n", 27Called ReceivePkt_Handler1
) = 27
ioctl(4, 0x1c, 0xbfb6e6f8) = 0
write(1, "Event ID = 0\n", 13Event ID = 0
) = 13
write(1, "Length Received = 3\n", 20Length Received = 3
) = 20
write(1, "OverFlow Length = 0\n", 20OverFlow Length = 0
) = 20
read(4, "\0\1\1", 3) = 3
fstat64(5, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1,
0) = 0xb7f07000
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [RT_15], = 0
clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr=0xbfb6e6b4) = 3659
waitpid(3659, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 3659
rt_sigaction(SIGINT, {SIG_DFL}, NULL, = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, = 0
rt_sigprocmask(SIG_SETMASK, [RT_15], NULL, = 0
--- SIGCHLD (Child exited) at (no spam) 0 (0) ---
write(1, "bytes_rcvd for tc0 =3,gConnectio"..., 55bytes_rcvd for tc0
=3,gConnectionInfo[0]->bytes_rcvd=3
) = 55
write(1, "Iteration=1,last descriptor\n", 28Iteration=1,last
descriptor
) = 28
write(1, "test........................\n",
29test........................
) = 29
write(5, "ABC", 3) = 3
close(5) = 0
munmap(0xb7f07000, 4096) = 0
write(1, "Tc0 - file closed successfully\n", 31Tc0 - file closed
successfully
) = 31
write(1, " file transferred = 2\n", 22 file transferred = 2
) = 22
write(1, "file_no_tc0=2\n", 14file_no_tc0=2
) = 14
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [RT_15], = 0
clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr=0xbfb6e684) = 3660
waitpid(3660, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 3660
rt_sigaction(SIGINT, {SIG_DFL}, NULL, = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, = 0
rt_sigprocmask(SIG_SETMASK, [RT_15], NULL, = 0
--- SIGCHLD (Child exited) at (no spam) 0 (0) ---
write(1, "3b passed\n", 103b passed
) = 10
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [RT_15], = 0
clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr=0xbfb6e684) = 3661
waitpid(3661, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 3661
rt_sigaction(SIGINT, {SIG_DFL}, NULL, = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, = 0
rt_sigprocmask(SIG_SETMASK, [RT_15], NULL, = 0
--- SIGCHLD (Child exited) at (no spam) 0 (0) ---
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [RT_15], = 0
clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr=0xbfb6e6b4) = 3662
waitpid(3662, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 3662
rt_sigaction(SIGINT, {SIG_DFL}, NULL, = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, = 0
rt_sigprocmask(SIG_SETMASK, [RT_15], NULL, = 0
--- SIGCHLD (Child exited) at (no spam) 0 (0) ---
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [RT_15], = 0
clone(child_stack=0, flags=CLONE_PARENT_SETTID|SIGCHLD,
parent_tidptr=0xbfb6e6b4) = 3663
waitpid(3663, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 3663
rt_sigaction(SIGINT, {SIG_DFL}, NULL, = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, = 0
rt_sigprocmask(SIG_SETMASK, [RT_15], NULL, = 0
--- SIGCHLD (Child exited) at (no spam) 0 (0) ---
write(1, " tx_file_no = 2\n", 16 tx_file_no = 2
) = 16
write(1, "tc0 - gConnectionInfo[0]->rx_fil"..., 53tc0 - gConnectionInfo
[0]->rx_file=/home/TestFiles/r3
) = 53
open("/home/TestFiles/r3", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 5
write(1, "futex RX Checking1\n", 19futex RX Checking1
) = 19
sigreturn() = ? (mask now [])
====================================================================
I think, fopen,fwrite,system are mapped to open, mmap and any of above
strace calls.
Please suggest me. will fwrite, fopen, system gives problem?
Thanks,
pandi
On Nov 28, 2:30 am, Christof Meerwald <NOSPAM-seeMySig
+up... at (no spam) usenet.cmeerw.org> wrote:
Quote: On Thu, 26 Nov 2009 01:09:16 -0800 (PST), pandi wrote:
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?
What about printf, system, fwrite, fclose, ...?
Please confirm since am not facing this problem periodically it is
very rare....
But occasional crashes/deadlocks/... are the expected behaviour as it
depends when exactly the signal gets delivered (i.e. if some internal data
structure is left in an inconsistent state) - welcome to the world of race
conditions and undefined behaviour.
Christof
--http://cmeerw.org sip:cmeerw at cmeerw.org
mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org |
|
|
| Back to top |
|
|
|
| David Schwartz... |
Posted: Fri Nov 27, 2009 8:18 pm |
|
|
|
Guest
|
On Nov 27, 7:25 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Quote: I think, fopen,fwrite,system are mapped to open, mmap and any of above
strace calls.
Please suggest me. will fwrite, fopen, system gives problem?
Thanks,
pandi
Yes, those calls are absolutely, definitely fatal in a signal handler.
They manipulate data structures that may be in an inconsistent state
when the signal arrives.
You should rearchitect your code. One way to fix it is to just set a
flag in the signal handler, then have your main code check the flag
and do whatever needs to be done. Another way is to have a dedicated
thread whose sole purpose is to wait for signals and handle them
synchronously.
But doing "real work" in an asynchronous signal handler that
interrupts arbitrary code is *very* bad.
DS |
|
|
| Back to top |
|
|
|
| pandi... |
Posted: Sun Nov 29, 2009 8:24 pm |
|
|
|
Guest
|
Hi..Thanks..I will select second option. It will be better for me if
you give me a examples/web link describes that thread receiving a
signal from kernel modules and wait for the signal from kernel
modules.
Thanks in advance...
On Nov 28, 11:18 am, David Schwartz <dav... at (no spam) webmaster.com> wrote:
Quote: On Nov 27, 7:25 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
I think, fopen,fwrite,system are mapped to open, mmap and any of above
strace calls.
Please suggest me. will fwrite, fopen, system gives problem?
Thanks,
pandi
Yes, those calls are absolutely, definitely fatal in a signal handler.
They manipulate data structures that may be in an inconsistent state
when the signal arrives.
You should rearchitect your code. One way to fix it is to just set a
flag in the signal handler, then have your main code check the flag
and do whatever needs to be done. Another way is to have a dedicated
thread whose sole purpose is to wait for signals and handle them
synchronously.
But doing "real work" in an asynchronous signal handler that
interrupts arbitrary code is *very* bad.
DS |
|
|
| Back to top |
|
|
|
| David Schwartz... |
Posted: Sun Nov 29, 2009 9:19 pm |
|
|
|
Guest
|
On Nov 29, 10:24 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Quote: Hi..Thanks..I will select second option. It will be better for me if
you give me a examples/web link describes that thread receiving a
signal from kernel modules and wait for the signal from kernel
modules.
The Linux man page for 'pthread_sigmask' contains an example of
exactly this. Make sure to block the signal in all threads using
either pthread_sigmask or sigaction. Then have the signal handling
thread call 'sigwait', typically in a loop.
DS |
|
|
| Back to top |
|
|
|
| pandi... |
Posted: Sun Nov 29, 2009 10:41 pm |
|
|
|
Guest
|
Ok I will do the same. Thanks for your ideas
On Nov 30, 12:19 pm, David Schwartz <dav... at (no spam) webmaster.com> wrote:
Quote: On Nov 29, 10:24 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Hi..Thanks..I will select second option. It will be better for me if
you give me a examples/web link describes that thread receiving a
signal from kernel modules and wait for the signal from kernel
modules.
The Linux man page for 'pthread_sigmask' contains an example of
exactly this. Make sure to block the signal in all threads using
either pthread_sigmask or sigaction. Then have the signal handling
thread call 'sigwait', typically in a loop.
DS |
|
|
| Back to top |
|
|
|
| pandi... |
Posted: Mon Nov 30, 2009 4:59 am |
|
|
|
Guest
|
Hi
After your suggestion, I'm able to work with single thread with signal
handling. However, am creating four thread with four signal mask and
waiting for a signal notification from my kernel modules. my kernel
modules using kill_proc notify the process. Here my understanding is
that all threads has to wake up and code written such that one thread
will run based on signal number it receiving. Is this possible to wake
up particular user thread instead of all threads from kernel modules?
and also it not wake up all thread if signal sends(kill_proc) to my
process...How to handler this type cases? Do i need to do any special
steps for thsi purpose?
Thanks.
On Nov 30, 1:41 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Quote: Ok I will do the same. Thanks for your ideas
On Nov 30, 12:19 pm, David Schwartz <dav... at (no spam) webmaster.com> wrote:
On Nov 29, 10:24 pm, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Hi..Thanks..I will select second option. It will be better for me if
you give me a examples/web link describes that thread receiving a
signal from kernel modules and wait for the signal from kernel
modules.
The Linux man page for 'pthread_sigmask' contains an example of
exactly this. Make sure to block the signal in all threads using
either pthread_sigmask or sigaction. Then have the signal handling
thread call 'sigwait', typically in a loop.
DS |
|
|
| Back to top |
|
|
|
| David Schwartz... |
Posted: Mon Nov 30, 2009 8:34 am |
|
|
|
Guest
|
On Nov 30, 6:59 am, pandi <pandiwelco... at (no spam) gmail.com> wrote:
Quote: After your suggestion, I'm able to work with single thread with signal
handling.
Great.
Quote: However, am creating four thread with four signal mask and
waiting for a signal notification from my kernel modules. my kernel
modules using kill_proc notify the process. Here my understanding is
that all threads has to wake up and code written such that one thread
will run based on signal number it receiving.
I'm not familiar with kill_proc, I would think you'd use send_sig. In
any event, it doesn't matter whether it sends it to all the threads
since the signal is blocked.
Quote: Is this possible to wake
up particular user thread instead of all threads from kernel modules?
Yes, but I don't recommend that. You should let the process determine
how what thread the signal goes to.
Quote: and also it not wake up all thread if signal sends(kill_proc) to my
process...How to handler this type cases? Do i need to do any special
steps for thsi purpose?
Since the signal is blocked in every thread but the one you care
about, why does it matter if the signal goes to these other threads?
In any event, the default behavior of sending an asynchronous signal
to a process that has that signal blocked in every thread but one is
to send that signal to the thread in which it is not blocked.
DS |
|
|
| Back to top |
|
|
|
|
|
All times are GMT - 5 Hours
The time now is Tue Dec 01, 2009 9:17 pm
|
|