[Csci551-talk] Regarding port-passing problems
Devarshi Shah
devarshi at ieee.org
Fri Mar 12 22:37:27 PST 2004
Yup.. I kinda agree with Mike. Fork clones the entire memory space - and I
have been able to get it to work using just this method. Pass the manager's
port in a variable and access it in the child process and you should be ok.
Moreover, I think that the project definition requires that the only
communication between the manager and the routers be using sockets...
--Devarshi
Devarshi P. Shah
--------------------------------------------------------------
Graduate Student (Computer Science),
University of Southern California, LA.
--------------------------------------------------------------
Web : http://devarshi.shah.name
email : devarshi at ieee.org
Cell : 323-363-3791, Home :323-373-0318
--------------------------------------------------------------
-----Original Message-----
From: csci551-talk-bounces at mailman.isi.edu
[mailto:csci551-talk-bounces at mailman.isi.edu] On Behalf Of michael wakerly
Sent: Friday, March 12, 2004 10:02 PM
To: csci551-talk at ISI.EDU
Subject: [Csci551-talk] Regarding port-passing problems
On Mar 12, 2004, at 7:57 PM, nishant agarwal wrote:
Keywords: Shared Memory, Semaphores, IPC
Whoa whoa... I read your message and it seems like when you wake up
tomorrow,
you're in
for a lot of overkill!
Recall that when you fork, the entire memory space is cloned. So, you can
set
any variable
you want, call fork, and that variable will be copied to the forked process.
If
you change it
later in your manager, the changes will only be propogated to subsequently
forked
processes.
So, consider the following psuedocode:
for each router:
int portnum = x++;
fork();
if is_child_process:
bind on portnum;
// etc ..
Unless you are going to want to change a portnum from the manager later down
the line,
there is no need for IPC/shared memory.
Else I could just create an array of information, and then do the forks.
Only
kernel descriptors of data strucutres remain valid, for eg: if you create
file
descriptors, or pipes and so on.
Actually, I think you got it right but are just too tired to realize it ;)
Just my ++$0.01 cents..
Mike
More information about the Csci551-talk
mailing list