|
-
Question about Unix programming
hey guys got some question about Unix programming. what is fork()? what does it use for? what is wait()? what is it used for? what is pipe()? what does it use for? can u give me some information coz, i have to write a simuation program which simulate a call center which a customer call in we direct the call to the call center
-
fork() creates a new process, and pipe is used for interprocess communication.
So you can have code like
if(fork())
{
//do child process stuff here
return;
}
//do parent process stuff here
to spawn processes.
for pipe it is a little trickier and I can't remember how to do it exactly without looking it up, but it allows processes to communicate with each other or signal each other - usually to let them know when one finishes or to signal to the other one it has data waiting etc. I kind of like shared memory better, but people seem to have massive problems with it.
I do not think that wait() actually works like you would expect.
Last time I was doing unix programming, there was no wait or sleep functions that actually did what you expect, though this may have changed since then.
I'm half Scottish and half French.
I surrender to alcohol.
-
Hammerhead Shark
I know what they do in Java, but it's been a while since I have done process forking in C++... I'd imagine wait() should work the same way, but who knows.
bryce777 basically explained it. I'm guessing you need handler processes that are forked off the main process to handle incoming connections, such as that in a socket handler class.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|