0

I want to achieve that one process should be keep on recieving the data from the client via the socket. another process is a timer task should be keep on running in parallel to call the tasks for every 2ms, 10ms and 100ms. I created a socket to recieve data and also the timer but i dont know how to run this task concurrently. could anyone help me by showing a example ??

2 Answers2

1

you can use fork() system call to create a child process and run the task concurrently.

Micha
  • 5,117
  • 8
  • 34
  • 47
Sarwan
  • 595
  • 3
  • 8
  • 21
  • for example : socket() - is an function call which recieved data from the clien. timer is an function call for creating the timer and calling the task for ever2ms, 10ms and 100ms. could you please give me an example for this ?? – user3354789 Mar 03 '14 at 09:52
1

It looks like threads might be a better option for you. There is a nice comparison of threads and processes here: When is clone() and fork better than pthreads?

Try looking at these tutorial to get the idea how to program pthreads: http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html

Community
  • 1
  • 1
Dmitry
  • 310
  • 4
  • 5