home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / internal / 1724 < prev    next >
Encoding:
Text File  |  1992-08-21  |  1.9 KB  |  55 lines

  1. Newsgroups: comp.unix.internals
  2. Path: sparky!uunet!destroyer!gatech!hubcap!news
  3. From: rsaripa@venus.cs.clemson.edu (Saripalli Ramakrishna)
  4. Subject: Thanks to all those who replied But..............
  5. Message-ID: <1992Aug21.163253.22219@hubcap.clemson.edu>
  6. Sender: news@hubcap.clemson.edu (news)
  7. Organization: Clemson University Computer Science Dept.
  8. Distribution: na
  9. Date: Fri, 21 Aug 1992 16:32:53 GMT
  10. Lines: 43
  11.  
  12. Hi,
  13.  
  14.     I really appreciate all those people who replied about the question
  15.     I had regarding the read/write access of a socket for some
  16.     related processes.
  17.  
  18.     What I really wanted was a sort of bus(say some channel) which all
  19.     related processes could write/read from.
  20.  
  21.     One end of the bus could be set up by the parent before fork() but
  22.     I am wondering how the other end could be set up.(It cannot be done
  23.     by the children ,of course).
  24.  
  25.     I think I made the problem clear.Also it has to be some kind of socket.
  26.     Also I feel that I need not use semaphores for the following segment
  27.     could do it as well.
  28.  
  29.     ......
  30.     do {
  31.     recv(sock_id,(char *) buffer,3 * sizeof(int),MSG_PEEK)
  32.     while (buffer.proc_id != getpid());
  33.     /*Now remove it from the stream using read()*/
  34.  
  35.     I feel that the above segment would do as well(though it is a waste
  36.     of CPU cycles) because all the processes would be executing this
  37.     code (or at least one process) and only the process for which this
  38.     message was meant would read the data and all others would be still
  39.     in the while loop.(Correct me if i am wrong)
  40.  
  41.     Now this to happen,all the children must be sharing a common bus
  42.     or channel or whatever so that recv() would succeed on it.
  43.  
  44.     In the above program segment,the control data is 3 words long
  45.     and the receiver's identity is in it(say process id or whatever).
  46.  
  47.     I would appreciate if anyone could tell me how I could do it?
  48.  
  49.  
  50.                         Thanks a lot,
  51.                     Saripalli Ramakrishna
  52.  
  53. e-mail : rsaripa@cs.clemson.edu
  54. Man is a beast and usually has no control over his passions.
  55.