LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-20-2011, 07:13 AM   #1
shakthi
LQ Newbie
 
Registered: May 2011
Posts: 11

Rep: Reputation: 0
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Related to pthreads and timers in POSIX standard geek89 Programming 2 02-18-2010 03:57 AM
Posix timers affected by system clock changes. ljratner Linux - Software 0 11-06-2009 03:39 PM
usage of Posix timers titusabraham Programming 5 10-13-2009 06:13 PM
Posix timers not behaving correctly sean04 Programming 1 10-07-2007 11:34 PM
posix timers mailsteam Programming 7 05-18-2007 11:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration