Lets say I have two functions that I want to run simultaneously for different purposes as example a function handles an XML RPC requests and the other function handles an IRC connection to an IRCD. what my goal would be to avoid program hang ups on user requests. Is pthreads capable of running functions in a way that they won't interfere with each others processing loops? I have been studying them and I seam to be unable to grasp a method that is efficient for processing two sources at once or with least lag. Can you share with me some methods on how you would do it? Try to keep in mind that I am new to C.

Thanks!

Edited 6 Years Ago by matthewl: n/a

Lets say I have two functions that I want to run simultaneously for different purposes as example a function handles an XML RPC requests and the other function handles an IRC connection to an IRCD. what my goal would be to avoid program hang ups on user requests. Is pthreads capable of running functions in a way that they won't interfere with each others processing loops? I have been studying them and I seam to be unable to grasp a method that is efficient for processing two sources at once or with least lag. Can you share with me some methods on how you would do it? Try to keep in mind that I am new to C.

Thanks!

The short answer is yes, try looking up mutex and semaphores both of these will protect shared resources from multi access...Threads are inherently dangerous, I heard a saying - "threads are a way for a programmer to shoot himself in both feet at the same time"

http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzahw/rzahwe19rx.htm

Edited 6 Years Ago by gerard4143: n/a

This article has been dead for over six months. Start a new discussion instead.