LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   posix timers issues and problem (https://www.linuxquestions.org/questions/linux-newbie-8/posix-timers-issues-and-problem-881788/)

shakthi 05-20-2011 07:13 AM

posix timers issues and problem
 
hi,

i have problem regarding posix timers which was used in socket and thread programming. i like to know whether timers will handle only one thread at a time?? If it is yes, how can we use timers to handle multiple threads at the same time... i have socket programming code

Quote:

Code:
/* server.c */
if(accept_of_client connection)
{
createthread(... func);
detachthread(..);
}


func()
{
timer_t timerid;
value...... sec =2;//sample
sa.sigev_notify=SIGEV_SIGNAL_THREAD;
sa.sigev_notify_function=(void*)&func1;
sa.sigev_notify_attributes=NULL;
timer_create (CLOCK_REALTIME, &sa, &timerid);


timer_settime (timerid, 0, &value, NULL);

while(1)
{
}

}
}
func1()
{
recv(from client);
send(from server to client);
}

}
the above one is just sample code which shows you about my concept. it should accept all the client connection at any time and every 2 or 3 secs it should check whether any msg received from client or not.... the whole code working very fine. it accept connection from the client and able to receive and send msg until another client came. if another client came,cant able to receive msg from the first client........ i dont know why this was happening?? after severe execution, i think whether posix timers or setitimer handle one thread at a time or not?? if it is yes, how to set each timer for each thread ( it means for each client).. please clarify my doubts as soon as possible...

with regards,
shakthi


All times are GMT -5. The time now is 11:42 PM.