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