The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Synchronize your databases with SqlSync iBot UNIX and Linux RSS News 0 05-08-2008 08:20 AM
how to synchronize different dirs reldb Shell Programming and Scripting 1 12-09-2006 05:08 PM
Solaris 9: How to set time/Synchronize 0ktalmagik UNIX for Advanced & Expert Users 3 07-16-2006 06:53 PM
How to synchronize all the linux machine? whatisthis Shell Programming and Scripting 1 11-12-2004 08:07 AM
synchronize as in java linuxpenguin High Level Programming 8 03-14-2004 06:02 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-19-2008
Registered User
 

Join Date: Mar 2008
Posts: 1
need a way to synchronize processes

I am writing a program in C for my networking class, so I am relatively new to this.
To begin, I have 7 processes that need do send messages to every other one, and every one of them needs to receive the messages sent by others.

I am using fork() to create 6 more processes.
The message sending should be done through UDP sockets. So I create 6 sockets for sending using bind() and then I do sendto()

After that the processes call receivefrom()
The problem is that sometimes the process does not catch the sent message, and so the program keeps on waiting for the rest of messages.
I try to rearrange sending and receiving, but ofcourse the scheduler does its own thing. I realize it needs a way to make them wait for each other, I am just not sure how to do it.

Thank you for any help!
Reply With Quote
Forum Sponsor
  #2  
Old 03-20-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
Use a mutex or possibly a sempahore set to each value 1 - 6 (or whatever)
There are several ways to implement IPC - interprocess communication -
Read chapter 5 here:
Download Advanced Linux Programming
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0